A hook that is triggered on any error or rejected Promise from any of the wix-data operations.
The onFailure()
hook is triggered whenever a wix-data operation or hook returns a
rejected Promise or an error.
function onFailure(error: Error, context: HookContext): Promise<object>;
The error that caused the failure.
Contextual information about the hook.
// In data.js
export function myCollection_onFailure(error, context) {
let hookError = error; // see below
// handle error
return ret;
}
/*
* hookError:
*
* {
* "message": "An item with _id [1234] already exists.",
* "code": -409
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.