throw Error object always

This commit is contained in:
blagoev 2017-10-02 13:29:53 +03:00
parent b4bc50aacf
commit 9fde587211

View File

@ -247,13 +247,16 @@ function sendRequest(command, data, host = sessionHost) {
error = error.replace(/^[a-z]+: /i, '');
}
else if (error.type && error.type == 'dict') {
let responseError = deserialize_json_value(error);
const responseError = deserialize_json_value(error);
let responeMessage;
if (response.message && response.message !== '') {
// Remove the type prefix from the error message (e.g. "Error: ").
responseError.message = response.message.replace(/^[a-z]+: /i, '');
responeMessage = response.message.replace(/^[a-z]+: /i, '');
}
throw responseError;
const exceptionToReport = new Error(responeMessage);
Object.assign(exceptionToReport, responseError);
throw exceptionToReport;
}
throw new Error(error || `Invalid response for "${command}"`);