Skip to main content

This guide will help you catch and react to errors coming from the Jabra library.

We divide errors into categories such as usage errors, unsupported features, device errors, and initialization errors.

Depending on the context, some of these errors should be communicated to the end-users and others are only relevant for you - the developer. The API Reference has a full list of error types, corresponding enum member values, and descriptions - see ErrorType.

See code sample

Catching errors#

All calls to Jabra APIs should be wrapped in try-catch blocks. Either as general try-catches or per call for better control.

The error object returned from the catch will be an instance of custom IJabraError object, which will provide an extra type property denoting what kind of error it is.

Example:

try {
device.offHook(true);
} catch (err) {
console.log(err.message); // Calls can only be started and stopped when the call lock is held.
console.log(err.type); // 'sdk-usage-error'
}

In this example, device.offHook(true) is called without first obtaining the callLock. This is an implementation error (see Call Control Tutorial) and something you should fix before releasing to end-users.

Typescript users can import the ErrorType enum from the main package. IntelliSense comments further explains the purpose of each error type, and when to expect it.

import { ErrorType } from '@gnaudio/jabra-js';
if (err.type === ErrorType.FEATURE_NOT_SUPPORTED) {
alert("Your device does not support this feature!");
}

Not using TypeScript? Please refer to ErrorType in the API Reference to get the different type strings.

Communicating errors to users#

Certain errors need to acted upon, especially errors related to unsupported features and initialization, hence these must be communicated to the end-user.

A scenario could be a user trying to perform an action not supported by the device such as trying to mute a device that does not have a microphone.

Initialization errors could mean that the user hasn't installed the Chrome Extension and the Native Console App. In that case, prompting the user to install these necessary components would be a good idea. Alternatively, if you're developing an app for a call center with central IT-administration, you might need to warn the administrator instead.