fix: Avoid using instanceof verification
MODIFY
lib/protocol/errors.js
lib/protocol/errors.js
@@ -164,17 +164,12 @@ class UnknownError extends ProtocolError {
static error () {
return W3C_UNKNOWN_ERROR;
}
- constructor (originalError) {
- let origMessage = originalError;
- if (originalError instanceof Error) {
- origMessage = originalError.message;
- }
- let message = 'An unknown server-side error occurred while processing ' +
- 'the command.';
- if (originalError) {
- message = `${message} Original error: ${origMessage}`;
- }
-
+ constructor (errorOrMessage) {
+ const origMessage = _.isString((errorOrMessage || {}).message)
+ ? errorOrMessage.message
+ : errorOrMessage;
+ const message = 'An unknown server-side error occurred while processing the command.' +
+ (origMessage ? ` Original error: ${origMessage}` : '');
super(message, UnknownError.code(), UnknownError.w3cStatus(), UnknownError.error());
}
}

fix: Avoid using instanceof verification (#356)