* 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 = '')
| 756 | * @return {ProtocolError} The error that is associated with provided JSONWP status code |
| 757 | */ |
| 758 | function 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 |
no test coverage detected
searching dependent graphs…