UNPKG

auth0

Version:

Auth0 Node.js SDK for the Management API v2.

33 lines (32 loc) 1.12 kB
"use strict"; // This file was auto-generated by Fern from our API Definition. Object.defineProperty(exports, "__esModule", { value: true }); exports.ManagementError = void 0; const json_js_1 = require("../core/json.js"); class ManagementError extends Error { constructor({ message, statusCode, body, rawResponse, }) { 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; } } exports.ManagementError = ManagementError; function buildMessage({ message, statusCode, body, }) { let 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"); }