Thomas,

consider the following function:

    public static DbException get(int errorCode, Throwable cause, String... 
params) {
        return new DbException(getJdbcSQLException(errorCode, cause, params));
    }



and

 catch (Exception e) {
            throw DbException.convert(e);
        }


noting that DbException.convert calls DbException.get().



This is one of the problems I have in converting the code to C++.  The code 
that I have cited is not proper form in C++....and I suspect it isn't in java 
either, but I am no expert on Java. The reason this code is not proper form 
(aside from the fact that you are throwing a pointer) is that  the new operator 
can itself throw an exception. So, right in the middle of handling an 
exception, you can cause a new exception to be thrown that masks the actual 
exception. ALso, if any of the internals of DbException throws, you have the 
same problem.

as for throwing pointers, standard practice in C++ is to throw classes and 
catch references to classes. Doing that is the way to make all the catch 
machinery work correctly and the way to handle the memory management for the 
exception correctly.

In C++, you avoid allocating any heap memory in exceptions or doing anything in 
its internals that could throw. 

So, I can't translate your complex exception handling cleanly to C++. I have an 
approximation that SHOULD always work, but it isn't airtight as exceptions are 
supposed to be. 


Is redesigning the exception handling to flatten it out and make it all 
guaranteed no-throw a goal you'd be interested in?

-James

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to