mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-19 04:17:44 +00:00
new error for HTTP responses without stack trace (#1044)
* new error for HTTP responses without stack trace * lint
This commit is contained in:
@@ -17,8 +17,17 @@ class PlayFileNotFoundError extends NonFatalTaskError {
|
||||
}
|
||||
}
|
||||
|
||||
class HTTPResponseError extends Error {
|
||||
constructor(statusCode) {
|
||||
super('Unexpected HTTP Response');
|
||||
delete this.stack;
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
SpeechCredentialError,
|
||||
NonFatalTaskError,
|
||||
PlayFileNotFoundError
|
||||
PlayFileNotFoundError,
|
||||
HTTPResponseError
|
||||
};
|
||||
|
||||
@@ -16,6 +16,7 @@ const {
|
||||
NODE_ENV,
|
||||
HTTP_USER_AGENT_HEADER,
|
||||
} = require('../config');
|
||||
const {HTTPResponseError} = require('./error');
|
||||
|
||||
const toBase64 = (str) => Buffer.from(str || '', 'utf8').toString('base64');
|
||||
|
||||
@@ -190,8 +191,7 @@ class HttpRequestor extends BaseRequestor {
|
||||
followRedirects: false
|
||||
});
|
||||
if (![200, 202, 204].includes(statusCode)) {
|
||||
const err = new Error();
|
||||
err.statusCode = statusCode;
|
||||
const err = new HTTPResponseError(statusCode);
|
||||
throw err;
|
||||
}
|
||||
if (headers['content-type']?.includes('application/json')) {
|
||||
|
||||
Reference in New Issue
Block a user