UNPKG

nylas

Version:

A NodeJS wrapper for the Nylas REST API for email, contacts, and calendar.

54 lines (53 loc) 1.71 kB
/** * Base class for all Nylas API errors. */ export class AbstractNylasApiError extends Error { } /** * Base class for all Nylas SDK errors. */ export class AbstractNylasSdkError extends Error { } /** * Class representation of a general Nylas API error. */ export class NylasApiError extends AbstractNylasApiError { constructor(apiError, statusCode, requestId, flowId, headers) { super(apiError.error.message); this.type = apiError.error.type; this.requestId = requestId; this.flowId = flowId; this.headers = headers; this.providerError = apiError.error.providerError; this.statusCode = statusCode; } } /** * Class representing an OAuth error returned by the Nylas API. */ export class NylasOAuthError extends AbstractNylasApiError { constructor(apiError, statusCode, requestId, flowId, headers) { super(apiError.errorDescription); this.error = apiError.error; this.errorCode = apiError.errorCode; this.errorDescription = apiError.errorDescription; this.errorUri = apiError.errorUri; this.statusCode = statusCode; this.requestId = requestId; this.flowId = flowId; this.headers = headers; } } /** * Error thrown when the Nylas SDK times out before receiving a response from the server */ export class NylasSdkTimeoutError extends AbstractNylasSdkError { constructor(url, timeout, requestId, flowId, headers) { super('Nylas SDK timed out before receiving a response from the server.'); this.url = url; this.timeout = timeout; this.requestId = requestId; this.flowId = flowId; this.headers = headers; } }