@marianmeres/http-utils 1.14.0 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +4 -3
- package/dist/index.js +4 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -290,12 +290,13 @@ const getErrorMessage = (e, stripErrorPrefix = true) => {
|
|
|
290
290
|
// e.cause is the standard prop for error details, so should be considered as
|
|
291
291
|
// the most authoritative (if available)
|
|
292
292
|
// "code" and "message" are my own conventions
|
|
293
|
-
cause?.
|
|
294
|
-
cause?.
|
|
293
|
+
cause?.message ||
|
|
294
|
+
cause?.code ||
|
|
295
295
|
(typeof cause === 'string' ? cause : null) ||
|
|
296
296
|
// non-standard "body" is this package's HttpError prop
|
|
297
297
|
body?.error?.message ||
|
|
298
298
|
body?.message ||
|
|
299
|
+
body?.error ||
|
|
299
300
|
(typeof body === 'string' ? body : null) ||
|
|
300
301
|
// the common message from Error ctor (e.g. "Foo" if new TypeError("Foo"))
|
|
301
302
|
e?.message ||
|
|
@@ -305,7 +306,7 @@ const getErrorMessage = (e, stripErrorPrefix = true) => {
|
|
|
305
306
|
e?.toString() ||
|
|
306
307
|
// very last fallback if `toString()` was not available (or returned empty)
|
|
307
308
|
'Unknown Error';
|
|
308
|
-
//
|
|
309
|
+
// ensure we're sending string
|
|
309
310
|
msg = `${msg}`;
|
|
310
311
|
if (stripErrorPrefix) {
|
|
311
312
|
msg = msg.replace(/^[^:]*Error: /, '');
|
package/dist/index.js
CHANGED
|
@@ -288,12 +288,13 @@ const getErrorMessage = (e, stripErrorPrefix = true) => {
|
|
|
288
288
|
// e.cause is the standard prop for error details, so should be considered as
|
|
289
289
|
// the most authoritative (if available)
|
|
290
290
|
// "code" and "message" are my own conventions
|
|
291
|
-
cause?.
|
|
292
|
-
cause?.
|
|
291
|
+
cause?.message ||
|
|
292
|
+
cause?.code ||
|
|
293
293
|
(typeof cause === 'string' ? cause : null) ||
|
|
294
294
|
// non-standard "body" is this package's HttpError prop
|
|
295
295
|
body?.error?.message ||
|
|
296
296
|
body?.message ||
|
|
297
|
+
body?.error ||
|
|
297
298
|
(typeof body === 'string' ? body : null) ||
|
|
298
299
|
// the common message from Error ctor (e.g. "Foo" if new TypeError("Foo"))
|
|
299
300
|
e?.message ||
|
|
@@ -303,7 +304,7 @@ const getErrorMessage = (e, stripErrorPrefix = true) => {
|
|
|
303
304
|
e?.toString() ||
|
|
304
305
|
// very last fallback if `toString()` was not available (or returned empty)
|
|
305
306
|
'Unknown Error';
|
|
306
|
-
//
|
|
307
|
+
// ensure we're sending string
|
|
307
308
|
msg = `${msg}`;
|
|
308
309
|
if (stripErrorPrefix) {
|
|
309
310
|
msg = msg.replace(/^[^:]*Error: /, '');
|