Hi,

I'm catching SQLException's in my application, in this case, trapping unique key 
violations and wanting to put up an appropriate error message (locale-specific, so I 
can't just use the error message). A portion of the code looks something like this:

  int errorCode = se.getErrorCode();
  if ( errorCode == Trace.VIOLATION_OF_UNIQUE_INDEX ) {
    // show the UK violation message, but this is never reached atm
  }

I'm pretty sure I'm using the wrong approach above (Fred has indicated the actual 
correct error code is the number at the start of the error message) - the errorCode 
being returned (1.7.0r6 I think) is actually -9, whereas Trace.VI..INDEX is defined as 
having a value of 9.

I can simply wrap my code in Math.abs(errorCode) to get this to work, but I figured 
I'd pose the question first to see if this is the correct way. There's a line in 
Trace.java where the error code is first converted to its absolute value, then 
returned as -code, which I thought a little strange.

Any suggestions would be appreciated.

Cheers,
Joe

------------------------------------------------------------
Joe Shevland                           [EMAIL PROTECTED]
Tasmania, Australia                   http://www.j-elite.com

Member, Systems Administrators Guild of Australia.

We must travel in the direction of our fear - John Berryman
------------------------------------------------------------


_______________________________________________________________

Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/
_______________________________________________
hsqldb-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hsqldb-developers

Reply via email to