MCPcopy
hub / github.com/appium/appium / errorFromMJSONWPStatusCode

Function errorFromMJSONWPStatusCode

lib/protocol/errors.js:758–768  ·  view source on GitHub ↗

* Retrieve an error derived from MJSONWP status * @param {number} code JSONWP status code * @param {string|Object} value The error message, or an object with a `message` property * @return {ProtocolError} The error that is associated with provided JSONWP status code

(code, value = '')

Source from the content-addressed store, hash-verified

756 * @return {ProtocolError} The error that is associated with provided JSONWP status code
757 */
758function errorFromMJSONWPStatusCode (code, value = '') {
759 // if `value` is an object, pull message from it, otherwise use the plain
760 // value, or default to an empty string, if null
761 const message = (value || {}).message || value || '';
762 if (code !== UnknownError.code() && jsonwpErrorCodeMap[code]) {
763 mjsonwpLog.debug(`Matched JSONWP error code ${code} to ${jsonwpErrorCodeMap[code].name}`);
764 return new jsonwpErrorCodeMap[code](message);
765 }
766 mjsonwpLog.debug(`Matched JSONWP error code ${code} to UnknownError`);
767 return new UnknownError(message);
768}
769
770/**
771 * Retrieve an error derived from W3C JSON Code

Callers 5

asyncHandlerFunction · 0.90
commandMethod · 0.90
getActualErrorMethod · 0.85
getResponseForW3CErrorFunction · 0.85
errors-specs.jsFile · 0.85

Calls 1

codeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…