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
- JavaScript (via package manager)
- Javascript (via CDN)
- TypeScript
// 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',
});
});
// 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
provider.onDisable(({ params }) => {
throw new window.AVMWebProviderSDK.ARC0027MethodSupportedError({
method: 'disable',
message: 'disable method is not supported',
providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
});
});
// 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
import { ARC0027MethodEnum, ARC0027MethodSupportedError } from '@agoralabs-sh/avm-web-provider';
provider.onDisable(({ params }) => {
throw new ARC0027MethodSupportedError({
method: ARC0027MethodEnum.Disable,
message: `${ARC0027MethodEnum.Disable} method is not supported`,
providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
});
});
note
The SDK provides several common errors, see errors.