Search...
onError( )
Adds an event handler that runs when an error occurs.
Description
An error can occur when attempting to resubscribe after a disconnection.
Errors that occur during the initial subscription process cause the
Promise returned by the subscribe()
function to reject
and do not trigger onError()
event handlers.
Syntax
function onError(handler: ErrorHandler): voidhandler: function ErrorHandler(error: Error): void
onError Parameters
NAME
TYPE
DESCRIPTION
Returns
This function does not return anything.
Return Type:
void
ErrorHandler Parameters
NAME
TYPE
DESCRIPTION
error
Error
The error that occurred.
Returns
This function does not return anything.
Return Type:
void
Was this helpful?
Add an error handler
Copy Code
1import wixRealtime from 'wix-realtime';23// ...45wixRealtime.onError( (error) => {6 let code = error.errorCode;7 let message = error.message;8 if(error.channel) {9 let channelName = error.channel.name;10 let resourceId = error.channel.resourceId;11 }12} );