UNPKG

@adobe/pdftools-extract-node-sdk

Version:

The Document Services PDF Tools Extract Node.js SDK provides APIs for extracting elements and renditions from PDF

75 lines (65 loc) 1.85 kB
/* * Copyright 2019 Adobe * All Rights Reserved. * * NOTICE: Adobe permits you to use, modify, and distribute this file in * accordance with the terms of the Adobe license agreement accompanying * it. If you have received this file from a source other than Adobe, * then your use, modification, or distribution of it requires the prior * written permission of Adobe. */ /** * The default value of status code if there is no status code for this service failure. * @memberOf ServiceUsageError * @instance * @type {number} */ const DEFAULT_STATUS_CODE = 429; /** * ServiceUsageError is thrown when either service usage limit has been reached or credentials quota has been exhausted. */ class ServiceUsageError extends Error { /** * @hideconstructor */ constructor(message, requestTrackingId, statusCode) { super(message); this.requestTrackingId = requestTrackingId; this.statusCode = statusCode || DEFAULT_STATUS_CODE; this.name = this.constructor.name; Error.captureStackTrace(this, this.constructor); } /** * Returns the HTTP Status code or {@link DEFAULT_STATUS_CODE} if the status code doesn't adequately represent the error. * * @returns {number} */ getStatusCode() { return this.statusCode; } /** * Returns the detailed message of this error. * * @return {string} the detail message */ getMessage() { return this.message; } /** * Returns the Request ID (the value of the X-Request-ID header). * * @returns {string} */ getRequestTrackingId() { return this.requestTrackingId; } /** * Returns a user-friendly interpretation of the current error instance. * @returns {string} */ toString() { return `description = ${this.message}; requestTrackingId = ${this.requestTrackingId }; statusCode = ${this.statusCode}`; } } module.exports = ServiceUsageError;