@@ -43,7 +43,7 @@ public DataException()
43
43
public DataException (int errorCode , SQLException ex , String sql )
44
44
{
45
45
super (errorCode );
46
- msg = ex . getMessage ( );
46
+ msg = getChainedMessage ( ex );
47
47
sqlState = ex .getSQLState ();
48
48
vendorErrorCode = ex .getErrorCode ();
49
49
this .sql = sql ;
@@ -60,10 +60,25 @@ public DataException(int errorCode, Object value, Exception cause)
60
60
initCause (cause );
61
61
}
62
62
63
+ private static String getChainedMessage (SQLException ex )
64
+ {
65
+ SQLException e = ex .getNextException ();
66
+ StringBuilder sb = new StringBuilder (ex .getMessage ());
67
+ while (e != null )
68
+ {
69
+ sb .append ("\n NextException: SQL Error: " ).append (e .getErrorCode ()) //
70
+ .append (", SQLState: " ).append (e .getSQLState ()) //
71
+ .append (", Message: " ).append (e .getMessage ());
72
+ e = e .getNextException ();
73
+ }
74
+ return sb .toString ();
75
+ }
76
+
77
+
63
78
// THIS METHOD IS REMOVED FROM InstanceJavaMethod WITH A HACK to keep compatibility with old ways :) - when ServoyException was not using js_...
64
79
/**
65
80
* @sameas com.servoy.j2db.util.ServoyException#js_isServoyException()
66
- *
81
+ *
67
82
* @deprecated Use "typeof" operator instead.
68
83
*/
69
84
@ Deprecated
@@ -77,7 +92,7 @@ public boolean js_isServoyException()
77
92
* This method will always return true; it makes the distinction between DataException and ServoyException.
78
93
*
79
94
* @deprecated Use "typeof" operator instead.
80
- *
95
+ *
81
96
* @sample
82
97
* var record = array[i];
83
98
* application.output(record.exception);
@@ -88,7 +103,7 @@ public boolean js_isServoyException()
88
103
* application.output("VendorErrorCode: " + record.exception.getVendorErrorCode());
89
104
* }
90
105
* @return true.
91
-
106
+
92
107
*/
93
108
@ Deprecated
94
109
public boolean js_isDataException ()
@@ -191,16 +206,16 @@ public int js_getVendorErrorCode()
191
206
192
207
/**
193
208
* Returns the parameters of the SQL query that caused this DataException in an array.
194
- *
209
+ *
195
210
* @sample
196
211
* var record = array[i];
197
212
* application.output(record.exception);
198
213
* if (record.exception instanceof DataException)
199
- * {
214
+ * {
200
215
* var param = record.exception.getParameters();
201
216
* for (j = 0; j < param.length; j++)
202
- * {
203
- * application.output("SQL Parameter [" + j + "]: " + param[j]);
217
+ * {
218
+ * application.output("SQL Parameter [" + j + "]: " + param[j]);
204
219
* }
205
220
* }
206
221
* @return the parameters of the SQL query that caused this DataException in an array.
0 commit comments