Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

The JSON event handlers allow you to include code at the end of each invoked function to handle error codes and display a message to the end user as required. If an error occurs, then the onErrorInvoke function is invoked immediately. The error message contains information regarding the error.
The typical format of an error invoke function is as follows:

function onErrorInvoke(rows){ 

Each row contains the error code and the error message.

If an Insert or an Update action is performed, then a message is returned according to the success or failure of the action is as follows:
If the Insert or Update action is successful, then the following is returned:

JavaScript error code 0 is returned 


If the Update or Insert action fails, then one of the following error codes is returned:

  • 101 - The SQL query is invalid. This error might be due to incorrect field names being used. The error message returned is sent from the database and indicates the location where the problem occurred.
  • 102 - Insert action was unsuccessful. The error message returned is sent from the database and indicates the location where the problem occurred.
  • 103 - Invalid action. This error message is returned if an action other than those actions that are defined is entered or mis-typed.
  • 104 - JSON is invalid. This error message indicates that there is a problem with the code, some of the functions in the code, or with parenthesis. The function in which the error occurs, is also returned.



The following example code shows how an error code is handled in a function. It is assumed that this code is entered at the end of an invoked function, which returns multiple rows as part of a dataset.

function onErrorInvoke(rows){ if(rows.length > 0){
window.location="melt://showAlert/"+ rows[0].message;
}
} 


This example states that if an error occurs, as long as the error does not relate to a blank row (no action performed), then display the message for the current row to the user.
Adding the following code to the invoked function returns row1 dataset, and displays any errors if there are any:

function onErrorInvoke(row1){ window.location="melt://showAlert/"+ row1.message;
} 
  • No labels