mirror of
https://github.com/donl/plivo-node.git
synced 2026-05-25 22:07:10 -06:00
20 lines
596 B
JavaScript
20 lines
596 B
JavaScript
|
|
class PlivoRestError extends Error {
|
|
constructor(response) {
|
|
response = response.response
|
|
var body;
|
|
super('[HTTP ' + response.status + '] Failed to execute request');
|
|
try {
|
|
body = typeof response.data === 'string' ? JSON.parse(response.data) : response.data;
|
|
} catch (err) {
|
|
body = {"error": response.data, "api_id": ''}
|
|
}
|
|
this.status = response.status;
|
|
this.statusText = response.statusText
|
|
this.message = body.error;
|
|
this.apiID = body.api_id;
|
|
this.moreInfo = response.config.data
|
|
}
|
|
}
|
|
|
|
module.exports = PlivoRestError;
|