Search...
onError( )
Adds an event handler that runs when an error occurs.
Description
The onError()
function allows you to perform actions after a dataset
operation causes an error such as a field failing validation.
The value of the handler's operation
property is the
name of the function that caused the error.
For example, the operation
property could be any of the following:
"new"
"next"
"save"
"previous"
Syntax
function onError(handler: ErrorHandler): voidhandler: function ErrorHandler(operation: string, error: DatasetError): void
onError Parameters
NAME
TYPE
DESCRIPTION
Returns
This function does not return anything.
Return Type:
void
ErrorHandler Parameters
NAME
TYPE
DESCRIPTION
operation
string
The operation during which the error occurred.
error
DatasetError
The error that occurred.
Returns
This function does not return anything.
Return Type:
void
Was this helpful?
Register a callback to run when an error occurs
Copy Code
1$w("#myDataset").onError( (operation, error) => {2 let errorOp = operation; // "save"34 let errorCode = error.code; // "DS_VALIDATION_ERROR"56 let errorMessage = error.message;7 // DatasetError: Some of the elements validation failed8} );