<!--
DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY, UNLESS YOU KNOW WHAT YOU'RE DOING.
THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO EXTRACT CHANGES FROM THE PAGE AND MERGE THEM BACK INTO SERVOY SOURC-->
{column:padding=0px|width=80px}{column}{column}{column}
Method Summery
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.
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 var e = arguments[0]; application.output("Exception Object: "+e) application.output("MSG: "+e.getMessage()) if (e instanceof ServoyException) { application.output("is a ServoyException") application.output("Errorcode: "+e.getErrorCode()) if (e.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) { application.output("SQL: "+record.exception.getSQL()) application.output("SQLState: "+record.exception.getSQLState()) application.output("VendorErrorCode: "+record.exception.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 var e = arguments[0]; application.output("Exception Object: "+e) application.output("MSG: "+e.getMessage()) if (e instanceof ServoyException) { application.output("is a ServoyException") application.output("Errorcode: "+e.getErrorCode()) if (e.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) { application.output("SQL: "+record.exception.getSQL()) application.output("SQLState: "+record.exception.getSQLState()) application.output("VendorErrorCode: "+record.exception.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()); }
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()); }