Search...
onFailure( )
A hook that is triggered on any error or rejected Promise from any of the wix-data operations.
Description
The onFailure()
hook is triggered whenever a wix-data operation or hook returns a
rejected Promise or an error.
Syntax
function onFailure(error: Error, context: HookContext): Promise<Object>
onFailure Parameters
NAME
TYPE
DESCRIPTION
error
Error
The error that caused the failure.
context
HookContext
Contextual information about the hook.
Returns
Fulfilled - Returning a fulfilled promise will result in a fulfilled data operation with the provided result. Rejected - Returning a rejected promise will result in returning a rejected promise to the caller of the data operation.
Return Type:
Promise<Object>
Was this helpful?
A hook triggered when a failure occurs
Copy Code
1// In data.js23export function myCollection_onFailure(error, context) {4 let hookError = error; // see below56 // handle error78 return ret;9}1011/*12 * hookError:13 *14 * {15 * "message": "An item with _id [1234] already exists.",16 * "code": -40917 * }18 */