Skip to main content

Throwing An Error

Overview

When receiving a request from the client, you can throw errors within the listener function and these errors will propagate back to the client's listener arguments.

Throwing an error

// AVMWebClient
client.onDisable(({ error, result }) => {
if (error) {
console.error(error);
/*
{
code: 4003,
data: {
method: 'disable',
},
message: 'disable method is not supported',
name: 'MethodNotSupportedError',
providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
}
*/

return;
}
});

// send a client request
client.disable();

// AVMWebProvider
const { ARC0027MethodSupportedError } = require('@agoralabs-sh/avm-web-provider');

provider.onDisable(({ params }) => {
throw new ARC0027MethodSupportedError({
method: 'disable',
message: 'disable method is not supported',
providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
});
});
note

The SDK provides several common errors, see errors.