//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
|