db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bryan Pendleton <bpendle...@amberpoint.com>
Subject Re: [jira] Commented: (DERBY-2472) Use Throwable.initCause() to improve error reporting
Date Sun, 20 May 2007 22:46:28 GMT
> 	} catch (StandardException e) {
> 		e.initCause(topLevelStandardException);
> 		topLevelStandardException = e;
> 	}

I don't quite understand the pattern above, probably because
I don't understand the purpose of the "topLevelStandardException"
variable. It seems like a more typical pattern for chaining
exceptions would be something like:

  	} catch (StandardException e) {
                 StandardException ourException =
                    StandardException.newException(SQLState.whatever...);
                 ourException.initCause(e);
                 throw ourException;
  	}

That is, we catch the lower-level exception, format our own
exception describing the informaiton that is relevant at this
level of the code, insert the lower level exception as being
the "cause" of our exception, then throw our exception.

That way, we only call initCause() once for each exception, because
we call it at the point that we construct and throw that exception.

Am I looking at this backwards?

thanks,

bryan


Mime
View raw message