nylas
Version:
A NodeJS wrapper for the Nylas REST API for email, contacts, and calendar.
62 lines (61 loc) • 2.15 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NylasSdkTimeoutError = exports.NylasOAuthError = exports.NylasApiError = exports.AbstractNylasSdkError = exports.AbstractNylasApiError = void 0;
/**
* Base class for all Nylas API errors.
*/
class AbstractNylasApiError extends Error {
}
exports.AbstractNylasApiError = AbstractNylasApiError;
/**
* Base class for all Nylas SDK errors.
*/
class AbstractNylasSdkError extends Error {
}
exports.AbstractNylasSdkError = AbstractNylasSdkError;
/**
* Class representation of a general Nylas API error.
*/
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;
}
}
exports.NylasApiError = NylasApiError;
/**
* Class representing an OAuth error returned by the Nylas API.
*/
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;
}
}
exports.NylasOAuthError = NylasOAuthError;
/**
* Error thrown when the Nylas SDK times out before receiving a response from the server
*/
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;
}
}
exports.NylasSdkTimeoutError = NylasSdkTimeoutError;