-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(error-message): Make error message on proxy call to be clearer
- Remove 'Unknown error' as generic message for other uncategorised error - Add more descriptive message and its error object to clarify it
- Loading branch information
Showing
7 changed files
with
288 additions
and
281 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* Return toString for any given value | ||
* @param {*} value any value, can be array, object, number, string, undefined, or null | ||
*/ | ||
const convertToString = (value) => { | ||
if (value === null) return 'null'; | ||
|
||
if(typeof value !== 'object') | ||
return String(value); | ||
|
||
if (Array.isArray(value)) { | ||
if (value.length == 0) return "[]"; | ||
|
||
let res = "["; | ||
for (const val of value) { | ||
if (typeof val === 'number') { | ||
res += (String(val) + ",") | ||
} else if (typeof val === 'object'){ | ||
res += `${convertToString(val)},`; | ||
} else { | ||
res += `"${convertToString(val)}",`; | ||
} | ||
} | ||
res = res.slice(0, res.length-1); | ||
res += "]" | ||
return res; | ||
} | ||
|
||
return JSON.stringify(value); | ||
} | ||
|
||
module.exports = { convertToString }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.