@coinbase/cdp-sdk
Version:
SDK for interacting with the Coinbase Developer Platform Wallet API
40 lines • 1.3 kB
JavaScript
;
// This file was auto-generated by Fern from our API Definition.
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoinbaseApiError = void 0;
const json_js_1 = require("../core/json.js");
class CoinbaseApiError extends Error {
statusCode;
body;
rawResponse;
cause;
constructor({ message, statusCode, body, rawResponse, cause, }) {
super(buildMessage({ message, statusCode, body }));
Object.setPrototypeOf(this, new.target.prototype);
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor);
}
this.name = this.constructor.name;
this.statusCode = statusCode;
this.body = body;
this.rawResponse = rawResponse;
if (cause != null) {
this.cause = cause;
}
}
}
exports.CoinbaseApiError = CoinbaseApiError;
function buildMessage({ message, statusCode, body, }) {
const lines = [];
if (message != null) {
lines.push(message);
}
if (statusCode != null) {
lines.push(`Status code: ${statusCode.toString()}`);
}
if (body != null) {
lines.push(`Body: ${(0, json_js_1.toJson)(body, undefined, 2)}`);
}
return lines.join("\n");
}
//# sourceMappingURL=CoinbaseApiError.js.map