@adobe/pdfservices-node-sdk
Version:
The Adobe PDF Services Node.js SDK provides APIs for creating, combining, exporting and manipulating PDFs.
80 lines • 2.92 kB
JavaScript
;
/*
* Copyright 2024 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ServiceApiError = void 0;
/**
* ServiceApiError is thrown when an underlying service API call results in an error.
*
* @see {@link SDKError}
* @see {@link ServiceUsageError}
*/
class ServiceApiError extends Error {
/**
* Constructs a `ServiceApiError` with the specified detail message, request tracking id, status code and
* error code.
* @param message error message detail
* @param requestTrackingId X-Request-Id header value to track the request
* @param statusCode HTTP Status code returned in API response
* @param errorCode Error code returned in API response
*/
constructor(message, requestTrackingId, statusCode, errorCode) {
super(message);
this._requestTrackingId = requestTrackingId;
this._statusCode = statusCode ?? ServiceApiError.DEFAULT_STATUS_CODE;
this._errorCode = errorCode ?? ServiceApiError.DEFAULT_ERROR_CODE;
}
/**
* Returns the detail message of this error.
*
* @returns the message detail.
*/
get message() {
return `description ='${super.message}'; requestTrackingId='${this.requestTrackingId}';
statusCode=${this.statusCode}; errorCode=${this.errorCode}`;
}
/**
* Returns the Request ID (the value of the X-Request-ID header).
*
* @returns Request ID
*/
get requestTrackingId() {
return this._requestTrackingId;
}
/**
* Returns the HTTP Status code or `DEFAULT_STATUS_CODE=0` if the status code doesn't adequately represent
* the error.
*
* @returns the HTTP Status code or `DEFAULT_STATUS_CODE=0` if the status code doesn't adequately represent
* the error.
*/
get statusCode() {
return this._statusCode;
}
/**
* Returns the Error code or `DEFAULT_ERROR_CODE="UNKNOWN"` if the error code doesn't adequately represent the error.
*
* @returns the Error code or `DEFAULT_ERROR_CODE="UNKNOWN"` if the error code doesn't adequately represent the error.
*/
get errorCode() {
return this._errorCode;
}
}
exports.ServiceApiError = ServiceApiError;
/**
* the default value of status code if there is no status code for this service failure.
*/
ServiceApiError.DEFAULT_STATUS_CODE = 0;
/**
* the default value of error code if there is no error code for this service failure.
*/
ServiceApiError.DEFAULT_ERROR_CODE = "UNKNOWN";
//# sourceMappingURL=ServiceApiError.js.map