UNPKG

box-node-sdk

Version:

Official SDK for Box Platform APIs

61 lines 2.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BoxApiError = exports.BoxSdkError = void 0; const errors_1 = require("../internal/errors"); const utils_1 = require("../internal/utils"); const logging_1 = require("../internal/logging"); class BoxSdkError extends errors_1.GeneratedCodeError { constructor(fields) { super(fields); this.name = 'BoxSdkError'; this.timestamp = fields.timestamp; this.error = fields.error; Object.setPrototypeOf(this, BoxSdkError.prototype); } } exports.BoxSdkError = BoxSdkError; class BoxApiError extends BoxSdkError { constructor(fields) { super(fields); this.dataSanitizer = new logging_1.DataSanitizer({}); this.name = 'BoxApiError'; this.requestInfo = fields.requestInfo; this.responseInfo = fields.responseInfo; if (fields.dataSanitizer) { this.dataSanitizer = fields.dataSanitizer; } Object.setPrototypeOf(this, BoxApiError.prototype); } [utils_1.utilLib.inspect.custom]() { return this.toString(); } toString() { return JSON.stringify(this.toJSON(), null, 2); } toJSON() { return { name: this.name, message: this.message, timestamp: this.timestamp, error: this.error, requestInfo: { method: this.requestInfo.method, url: this.requestInfo.url, queryParams: this.requestInfo.queryParams, headers: this.dataSanitizer.sanitizeHeaders(this.requestInfo.headers), body: this.requestInfo.body, }, responseInfo: { statusCode: this.responseInfo.statusCode, headers: this.dataSanitizer.sanitizeHeaders(this.responseInfo.headers), body: this.dataSanitizer.sanitizeBody(this.responseInfo.body), code: this.responseInfo.code, contextInfo: this.responseInfo.contextInfo, requestId: this.responseInfo.requestId, helpUrl: this.responseInfo.helpUrl, }, }; } } exports.BoxApiError = BoxApiError; //# sourceMappingURL=errors.js.map