@mll-lab/js-utils 2.4.0 → 2.5.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/error.d.ts +7 -0
- package/dist/error.test.d.ts +1 -0
- package/dist/index.common.js +18 -0
- package/dist/index.common.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/error.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.common.js
CHANGED
|
@@ -15111,6 +15111,23 @@ function formatDotlessDate(date) {
|
|
|
15111
15111
|
return format(date, DOTLESS_DATE_FORMAT, { locale: de$1 });
|
|
15112
15112
|
}
|
|
15113
15113
|
|
|
15114
|
+
/**
|
|
15115
|
+
* Extract a message from a caught error.
|
|
15116
|
+
*
|
|
15117
|
+
* Since you can throw anything in JavaScript,
|
|
15118
|
+
* the given error could be of any type.
|
|
15119
|
+
*/
|
|
15120
|
+
function errorMessage(error) {
|
|
15121
|
+
const message = hasMessage(error) ? error.message : error;
|
|
15122
|
+
if (message === undefined) {
|
|
15123
|
+
return 'undefined';
|
|
15124
|
+
}
|
|
15125
|
+
return typeof message === 'string' ? message : JSON.stringify(error);
|
|
15126
|
+
}
|
|
15127
|
+
function hasMessage(error) {
|
|
15128
|
+
return typeof error === 'object' && error !== null && 'message' in error;
|
|
15129
|
+
}
|
|
15130
|
+
|
|
15114
15131
|
function pluralize(amount, singular, plural) {
|
|
15115
15132
|
if (amount === 1) {
|
|
15116
15133
|
return singular;
|
|
@@ -15181,6 +15198,7 @@ exports.ISO_DATE_FORMAT = ISO_DATE_FORMAT;
|
|
|
15181
15198
|
exports.ISO_DATE_TIME_FORMAT = ISO_DATE_TIME_FORMAT;
|
|
15182
15199
|
exports.SECONDLESS_DATE_TIME_FORMAT = SECONDLESS_DATE_TIME_FORMAT;
|
|
15183
15200
|
exports.containSameValues = containSameValues;
|
|
15201
|
+
exports.errorMessage = errorMessage;
|
|
15184
15202
|
exports.firstLine = firstLine;
|
|
15185
15203
|
exports.formatDotlessDate = formatDotlessDate;
|
|
15186
15204
|
exports.formatGerman = formatGerman;
|