mirror of
https://github.com/appium/appium.git
synced 2026-10-22 08:46:25 +08:00
19 lines
652 B
TypeScript
19 lines
652 B
TypeScript
import _ from 'lodash';
|
|
import { errors, getResponseForW3CError } from 'appium/driver';
|
|
|
|
|
|
export function toW3cResponseError(err: any): [number, Record<string, any>] {
|
|
if (_.isFunction(getResponseForW3CError)) {
|
|
return getResponseForW3CError(err) as [number, Record<string, any>];
|
|
}
|
|
// TODO: deprecate the below after the plugin only supports Appium3+
|
|
const protocolError = _.has(err, 'w3cStatus') ? err : new errors.UnknownError(err);
|
|
return [protocolError.w3cStatus, {
|
|
value: {
|
|
error: protocolError.error,
|
|
message: protocolError.message,
|
|
stacktrace: protocolError.stacktrace || protocolError.stack,
|
|
},
|
|
}];
|
|
}
|