Auto-commit 2026-04-29 16:31
This commit is contained in:
33
node_modules/twilio/lib/base/RestException.js
generated
vendored
Normal file
33
node_modules/twilio/lib/base/RestException.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
class RestException extends Error {
|
||||
constructor(response) {
|
||||
super("[HTTP " + response.statusCode + "] Failed to execute request");
|
||||
const isResponseBodyString = typeof response.body == "string";
|
||||
const body = isResponseBodyString
|
||||
? parseResponseBody(response.body)
|
||||
: response.body;
|
||||
this.status = response.statusCode;
|
||||
if (body !== null) {
|
||||
this.message = body.message;
|
||||
this.code = body.code;
|
||||
this.moreInfo = body.more_info; /* jshint ignore:line */
|
||||
this.details = body.details;
|
||||
}
|
||||
else {
|
||||
this.message =
|
||||
"[HTTP " + response.statusCode + "] Failed to execute request";
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.default = RestException;
|
||||
function parseResponseBody(response_body) {
|
||||
let body = null;
|
||||
try {
|
||||
body = JSON.parse(response_body);
|
||||
}
|
||||
catch (catchError) {
|
||||
body = null;
|
||||
}
|
||||
return body;
|
||||
}
|
||||
Reference in New Issue
Block a user