{column:padding=0px|width=80px}{column}{column}{column}
Method Summary
getErrorCode()
Returns the error code for this ServoyException.
getMessage()
Returns the string message for this ServoyException.
Object[]
getParameters()
Returns the parameters of the SQL query that caused this DataException in an array.
getSQLState()
Returns the SQLState for this DataException.
getStackTrace()
Returns the stack trace for this ServoyException.
getVendorErrorCode()
Returns the error code of the error thrown by the back-end database server.
{column:padding=0px|width=100%}{column}
Method Details
getErrorCode
()
Returns the error code for this ServoyException. Can be one of the constants declared in ServoyException.
Since
Replace with version info
Parameters
Returns
[Number] – the error code for this ServoyException. Can be one of the constants declared in ServoyException.
Also see
External links
Sample
//this sample script should be attached to onError method handler in the solution settings application.output('Exception Object: '+ex) application.output('MSG: '+ex.getMessage()) if (ex instanceof ServoyException) { /** @type {ServoyException} */ var servoyException = ex; application.output("is a ServoyException") application.output("Errorcode: "+servoyException.getErrorCode()) var trace = ""; if (ex.getScriptStackTrace) trace = servoyException.getScriptStackTrace(); else if (servoyException.getStackTrace) trace = servoyException.getStackTrace(); if (servoyException.getErrorCode() == ServoyException.SAVE_FAILED) { plugins.dialogs.showErrorDialog( 'Error', 'It seems you did not fill in a required field', 'OK'); //Get the failed records after a save var array = databaseManager.getFailedRecords() for( var i = 0 ; i < array.length ; i++ ) { var record = array[i]; application.output(record.exception); if (record.exception instanceof DataException) { /** @type {DataException} */ var dataException = record.exception; application.output('SQL: '+dataException.getSQL()) application.output('SQLState: '+dataException.getSQLState()) application.output('VendorErrorCode: '+dataException.getVendorErrorCode()) } } return false } } //if returns false or no return, error is not reported to client; if returns true error is reported //by default error report means logging the error, in smart client an error dialog will also show up return true
getMessage
()
Returns the string message for this ServoyException.
Since
Replace with version info
Parameters
Returns
[String] – the string message for this ServoyException.
Also see
External links
Sample
//this sample script should be attached to onError method handler in the solution settings application.output('Exception Object: '+ex) application.output('MSG: '+ex.getMessage()) if (ex instanceof ServoyException) { /** @type {ServoyException} */ var servoyException = ex; application.output("is a ServoyException") application.output("Errorcode: "+servoyException.getErrorCode()) var trace = ""; if (ex.getScriptStackTrace) trace = servoyException.getScriptStackTrace(); else if (servoyException.getStackTrace) trace = servoyException.getStackTrace(); if (servoyException.getErrorCode() == ServoyException.SAVE_FAILED) { plugins.dialogs.showErrorDialog( 'Error', 'It seems you did not fill in a required field', 'OK'); //Get the failed records after a save var array = databaseManager.getFailedRecords() for( var i = 0 ; i < array.length ; i++ ) { var record = array[i]; application.output(record.exception); if (record.exception instanceof DataException) { /** @type {DataException} */ var dataException = record.exception; application.output('SQL: '+dataException.getSQL()) application.output('SQLState: '+dataException.getSQLState()) application.output('VendorErrorCode: '+dataException.getVendorErrorCode()) } } return false } } //if returns false or no return, error is not reported to client; if returns true error is reported //by default error report means logging the error, in smart client an error dialog will also show up return true
Object[]
getParameters
()
Returns the parameters of the SQL query that caused this DataException in an array.
Since
Replace with version info
Parameters
Returns
[Object][] – the parameters of the SQL query that caused this DataException in an array.
Also see
External links
Sample
var record = array[i]; application.output(record.exception); if (record.exception instanceof DataException) { var param = record.exception.getParameters(); for (j = 0; j < param.length; j++) { application.output("SQL Parameter [" + j + "]: " + param[j]); } }
getSQL
()
Returns the SQL query that caused this DataException.
Since
Replace with version info
Parameters
Returns
[String] – the SQL query that caused this DataException.
Also see
External links
Sample
var record = array[i]; application.output(record.exception); if (record.exception instanceof DataException) { application.output("SQL: " + record.exception.getSQL()); }
getSQLState
()
Returns the SQLState for this DataException.
This is a "SQLstate" string, which follows either the XOPEN SQLstate conventions or the SQL 99 conventions.
The values of the SQLState string are described in the appropriate spec.
Since
Replace with version info
Parameters
Returns
[String] – the SQLState for this DataException.
Also see
External links
Sample
var record = array[i]; application.output(record.exception); if (record.exception instanceof DataException) { application.output("SQLState: " + record.exception.getSQLState()); }
getStackTrace
()
Returns the stack trace for this ServoyException.
Since
Replace with version info
Parameters
Returns
[String] – the string stack trace for this ServoyException.
Also see
External links
Sample
//this sample script should be attached to onError method handler in the solution settings application.output('Exception Object: '+ex) application.output('MSG: '+ex.getMessage()) if (ex instanceof ServoyException) { /** @type {ServoyException} */ var servoyException = ex; application.output("is a ServoyException") application.output("Errorcode: "+servoyException.getErrorCode()) var trace = ""; if (ex.getScriptStackTrace) trace = servoyException.getScriptStackTrace(); else if (servoyException.getStackTrace) trace = servoyException.getStackTrace(); if (servoyException.getErrorCode() == ServoyException.SAVE_FAILED) { plugins.dialogs.showErrorDialog( 'Error', 'It seems you did not fill in a required field', 'OK'); //Get the failed records after a save var array = databaseManager.getFailedRecords() for( var i = 0 ; i < array.length ; i++ ) { var record = array[i]; application.output(record.exception); if (record.exception instanceof DataException) { /** @type {DataException} */ var dataException = record.exception; application.output('SQL: '+dataException.getSQL()) application.output('SQLState: '+dataException.getSQLState()) application.output('VendorErrorCode: '+dataException.getVendorErrorCode()) } } return false } } //if returns false or no return, error is not reported to client; if returns true error is reported //by default error report means logging the error, in smart client an error dialog will also show up return true
getValue
()
Returns the value for this DataException.
The value is the object thrown in table pre-insert, pre-update or pre-delete triggers.
Since
Replace with version info
Parameters
Returns
[Object] – the value for this DataException.
Also see
External links
Sample
var record = array[i]; application.output(record.exception); if (record.exception instanceof DataException) { application.output("VALUE: " + record.exception.getValue()); }
getVendorErrorCode
()
Returns the error code of the error thrown by the back-end database server.
Since
Replace with version info
Parameters
Returns
[Number] – the error code of the error thrown by the back-end database server.
Also see
External links
Sample
var record = array[i]; application.output(record.exception); if (record.exception instanceof DataException) { application.output("VendorErrorCode: " + record.exception.getVendorErrorCode()); }