32
32
import com .sun .star .resource .XStringResourceResolver ;
33
33
import com .sun .star .sdbc .SQLException ;
34
34
import com .sun .star .sdbc .XRow ;
35
- import com .sun .star .uno .Any ;
36
35
import com .sun .star .uno .AnyConverter ;
37
36
import com .sun .star .uno .Exception ;
38
37
import com .sun .star .uno .RuntimeException ;
@@ -366,19 +365,19 @@ public static WrappedTargetException getWrappedException(Exception e)
366
365
return exception ;
367
366
}
368
367
369
- public static java .sql .SQLException getSQLException (java .lang .Exception e )
368
+ public static java .sql .SQLException getSQLException (java .lang .Throwable e )
370
369
{
371
- return new java .sql .SQLException (e .getMessage (), e );
370
+ return new java .sql .SQLException (e .getLocalizedMessage (), e );
372
371
}
373
372
374
373
public static SQLException getSQLException (java .sql .SQLException e )
375
374
{
376
- return new SQLException (e .getMessage ());
375
+ return getUnoSQLException (e .getLocalizedMessage ());
377
376
}
378
377
379
378
public static SQLException getSQLException (Exception e , XInterface component )
380
379
{
381
- SQLException exception = new SQLException (e .getMessage ());
380
+ SQLException exception = getUnoSQLException (e .getMessage ());
382
381
exception .Context = component ;
383
382
return exception ;
384
383
}
@@ -387,25 +386,36 @@ public static SQLException getSQLException(java.sql.SQLException e, XInterface c
387
386
{
388
387
SQLException exception = null ;
389
388
if (e != null ) {
390
- exception = new SQLException (e .getMessage ());
389
+ exception = getUnoSQLException (e .getLocalizedMessage ());
391
390
exception .Context = component ;
392
- exception .SQLState = e .getSQLState ();
391
+ String state = e .getSQLState ();
392
+ if (state != null ) {
393
+ exception .SQLState = state ;
394
+ }
393
395
exception .ErrorCode = e .getErrorCode ();
394
396
SQLException ex = getNextSQLException (e .getNextException (), component );
395
- exception .NextException = (ex == null ) ? Any .VOID : ex ;
397
+ if (ex != null ) {
398
+ exception .NextException = ex ;
399
+ }
396
400
}
397
401
return exception ;
398
402
}
399
403
404
+ private static SQLException getUnoSQLException (String msg )
405
+ {
406
+ return msg != null ? new SQLException (msg ) : new SQLException ();
407
+ }
408
+
400
409
public static SQLException getSQLException (java .lang .Exception e ,
401
410
XInterface component )
402
411
{
403
- SQLException exception = new SQLException (e .getMessage ());
412
+ SQLException exception = getUnoSQLException (e .getMessage ());
404
413
exception .Context = component ;
405
414
return exception ;
406
415
}
407
416
408
- private static SQLException getNextSQLException (java .sql .SQLException e , XInterface component )
417
+ private static SQLException getNextSQLException (java .sql .SQLException e ,
418
+ XInterface component )
409
419
{
410
420
SQLException exception = null ;
411
421
if (e != null ) {
0 commit comments