(responseData)
| 1 | const INVALID_ERROR_STRINGS = new Set(["[object Object]", "undefined", "null", ""]); |
| 2 | |
| 3 | const pickResponseMessage = (responseData) => { |
| 4 | if (typeof responseData === "string") { |
| 5 | return responseData.trim(); |
| 6 | } |
| 7 | if (!responseData || typeof responseData !== "object") { |
| 8 | return ""; |
| 9 | } |
| 10 | |
| 11 | const keys = ["message", "error", "detail", "details", "msg"]; |
| 12 | for (const key of keys) { |
| 13 | const value = responseData[key]; |
| 14 | if (typeof value === "string" && value.trim()) { |
| 15 | return value.trim(); |
| 16 | } |
| 17 | } |
| 18 | return ""; |
| 19 | }; |
| 20 | |
| 21 | export const resolveErrorMessage = (err, fallbackMessage = "") => { |
| 22 | if (typeof err === "string") { |
no outgoing calls
no test coverage detected