Whenever, Servoy encounters any error, it throws the Exception with the message. To add your own customized message, which will be more user friendly, you can attach an Exception handler to your solution.
Exception Handler is just a Global Method which will be get fired automatically, whenever servoy encounters any error and the Exception will be passed to the method as an argument. You can add the Exception handler to your Solution by setting the global method(Exception handler) to the onError event of the solution.
Exception Handler is just a Global Method which will be get fired automatically, whenever servoy encounters any error and the Exception will be passed to the method as an argument. You can add the Exception handler to your Solution by setting the global method(Exception handler) to the onError event of the solution.
[Servoy 3.1+ & 3.5+]
Open the Solution -> Go to File menu -> Solution Settings -> Select the Global Method from the On error method drop down.
[Servoy 4.0+]
Select the solution -> Go to Properties Tab -> select the Global Method to the onError event.
Here is the sample code snippet, that you can add to your Global Method(Exception Handler) to show customized messages to the user.
Here is the sample code snippet, that you can add to your Global Method(Exception Handler) to show customized messages to the user.
var svyExpList = new java.util.HashMap();
//Add your message to the respective Exceptions
svyExpList.put(ServoyException.ACQUIRE_LOCK_FAILURE, "Acquire Lock Failure");
svyExpList.put(ServoyException.BAD_SQL_SYNTAX, "Bad Sql Syntax");
svyExpList.put(ServoyException.DATA_ACCESS_RESOURCE_FAILURE, "Data Access Failure");
svyExpList.put(ServoyException.DATA_INTEGRITY_VIOLATION, "Data Integrity Violation.");
svyExpList.put(ServoyException.DEADLOCK, "Dead Lock");
svyExpList.put(ServoyException.DELETE_NOT_GRANTED, "Delete not Granted.");
svyExpList.put(ServoyException.EXECUTE_PROGRAM_FAILED, "Execute Program failed.");
svyExpList.put(ServoyException.INCORRECT_LOGIN, "Incorrect login");
svyExpList.put(ServoyException.INVALID_INPUT, "Invalid Input");
svyExpList.put(ServoyException.INVALID_INPUT_FORMAT, "Invalid Input Format");
svyExpList.put(ServoyException.INVALID_RESULTSET_ACCESS, "Invalid Resultset Access");
svyExpList.put(ServoyException.NO_ACCESS, "No Access");
svyExpList.put(ServoyException.NO_CREATE_ACCESS, "No Create Access");
svyExpList.put(ServoyException.NO_DELETE_ACCESS, "No Delete Access");
svyExpList.put(ServoyException.NO_LICENSE, "No License");
svyExpList.put(ServoyException.NO_MODIFY_ACCESS, "No Modify Access");
svyExpList.put(ServoyException.NO_PARENT_DELETE_WITH_RELATED_RECORDS, "No Parent Delete with Related Record");
svyExpList.put(ServoyException.NO_RELATED_CREATE_ACCESS, "No Related Create Access");
svyExpList.put(ServoyException.PERMISSION_DENIED, "Permission Denaid");
svyExpList.put(ServoyException.RECORD_LOCKED, "Record Locked");
svyExpList.put(ServoyException.SAVE_FAILED, "Save Failed");
svyExpList.put(ServoyException.UNKNOWN_DATABASE_EXCEPTION, "Unknown Database Exception");
var exception = arguments[0]; //Occurred Exception
if (exception.isServoyException) //Servoy Exception
{
var msg = svyExpList.get(exception.getErrorCode());
plugins.dialogs.showErrorDialog( "Error Occured !!", msg, 'OK');
}
Add your own messages to each Exception to show the user a proper message.
0 comments:
Post a Comment