Errors

Every error class calsdk throws, its fields and when it is thrown.

When a call fails, the error's class tells you what went wrong and its fields tell you where. All errors extend CalsdkError, which extends Error. Every class has a static isInstance(error) check that works across duplicated package copies. Errors from a provider keep the original failure in cause.

import { NotFoundError } from '@cal-sdk/core';

if (NotFoundError.isInstance(error)) console.log(error.resource, error.id);

Errors and retries covers how to handle them.

Input and setup

ClassFieldsThrown when
InvalidArgumentErrorargumentAn option is invalid. argument is its path, such as 'event.start.timeZone'
NoSuchProviderVersionErrorprovider, versionThe provider implements a contract version this calsdk does not know
UnsupportedFunctionalityErrorprovider, functionalityThe provider cannot do what was asked

Provider responses

ClassFieldsThrown when
AuthenticationErrorproviderCredentials were rejected (401)
PermissionDeniedErrorproviderThe user may not do this (403)
NotFoundErrorprovider, resource ('calendar' or 'event'), idThe calendar or event does not exist, was deleted or is hidden (404, 410)
ConflictErrorprovider, eventIdifMatch no longer matches (412)
RateLimitErrorprovider, retryAfterMs?, isRetryable (always true)The provider is throttling (429)
SyncCursorExpiredErrorprovider, calendarIdThe provider no longer accepts the sync cursor
InvalidResponseDataErrordataThe provider returned data in a shape calsdk does not expect. The message leaves the data out
APICallErrorurl, statusCode?, responseHeaders?, responseBody?, isRetryableAny other failed request, including network errors

APICallError.isRetryable is true for 408, 429, 5xx and network failures. Request headers are never stored on it, since they carry the token.

Free time

ClassFieldsThrown when
FreeBusyUnavailableErrorprovider, calendarIdfindFreeTime could not read one of the calendars

NotFoundError, SyncCursorExpiredError and FreeBusyUnavailableError leave calendar ids out of their messages, since they are often email addresses. Read them from the fields.

On this page