@itwin/core-i18n 5.7.0-dev.15 → 5.7.0-dev.16
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/lib/cjs/test/webpack/bundled-tests.instrumented.js +175 -147
- package/lib/cjs/test/webpack/bundled-tests.instrumented.js.map +1 -1
- package/lib/cjs/test/webpack/bundled-tests.js +44 -16
- package/lib/cjs/test/webpack/bundled-tests.js.map +1 -1
- package/lib/cjs/test/webpack/vendors-common_temp_node_modules_pnpm_cross-fetch_4_0_0_node_modules_cross-fetch_dist_browser-24291b.bundled-tests.instrumented.js.map +1 -1
- package/lib/cjs/test/webpack/vendors-common_temp_node_modules_pnpm_cross-fetch_4_0_0_node_modules_cross-fetch_dist_browser-24291b.bundled-tests.js.map +1 -1
- package/package.json +6 -6
|
@@ -18874,30 +18874,58 @@ class Logger {
|
|
|
18874
18874
|
const minLevel = Logger.getLevel(category);
|
|
18875
18875
|
return (minLevel !== undefined) && (level >= minLevel);
|
|
18876
18876
|
}
|
|
18877
|
-
|
|
18878
|
-
|
|
18879
|
-
|
|
18880
|
-
|
|
18881
|
-
|
|
18882
|
-
|
|
18883
|
-
|
|
18884
|
-
|
|
18877
|
+
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
18878
|
+
static logError(category, messageOrError, metaData) {
|
|
18879
|
+
if (Logger._logError && Logger.isEnabled(category, LogLevel.Error)) {
|
|
18880
|
+
if (typeof messageOrError === "string") {
|
|
18881
|
+
Logger._logError(category, messageOrError, metaData);
|
|
18882
|
+
}
|
|
18883
|
+
else if (_BentleyError__WEBPACK_IMPORTED_MODULE_1__.BentleyError.isError(messageOrError)) {
|
|
18884
|
+
// For backwards compatibility, log BentleyError old way
|
|
18885
|
+
Logger._logError(category, Logger.getExceptionMessage(messageOrError), () => ({ ..._BentleyError__WEBPACK_IMPORTED_MODULE_1__.BentleyError.getErrorMetadata(messageOrError), exceptionType: messageOrError?.constructor?.name ?? "<Unknown>", ..._BentleyError__WEBPACK_IMPORTED_MODULE_1__.BentleyError.getMetaData(metaData) }));
|
|
18886
|
+
}
|
|
18887
|
+
else {
|
|
18888
|
+
// Else, return a copy of the error, with non-enumerable members `message` and `stack` removed, as "metadata" for log.
|
|
18889
|
+
Logger._logError(category, Logger.getExceptionMessage(messageOrError), Logger.getExceptionMetaData(messageOrError, metaData));
|
|
18890
|
+
}
|
|
18891
|
+
}
|
|
18885
18892
|
}
|
|
18886
|
-
|
|
18887
|
-
|
|
18888
|
-
|
|
18893
|
+
/**
|
|
18894
|
+
* Get a sting message for a given error.
|
|
18895
|
+
* For legacy [[BentleyError]] exceptions, this will include the error message and, optionally, the call stack.
|
|
18896
|
+
* For other exceptions, this will include the stringified version of the error.
|
|
18897
|
+
* @param error The error to get the message for
|
|
18898
|
+
* @returns A string message for the error
|
|
18899
|
+
*/
|
|
18900
|
+
static getExceptionMessage(error) {
|
|
18901
|
+
if (error === undefined) {
|
|
18902
|
+
return "Error: error is undefined.";
|
|
18903
|
+
}
|
|
18904
|
+
if (error === null) {
|
|
18905
|
+
return "Error: error is null.";
|
|
18889
18906
|
}
|
|
18890
|
-
|
|
18891
|
-
|
|
18907
|
+
const stack = Logger.logExceptionCallstacks ? `\n${_BentleyError__WEBPACK_IMPORTED_MODULE_1__.BentleyError.getErrorStack(error)}` : "";
|
|
18908
|
+
return _BentleyError__WEBPACK_IMPORTED_MODULE_1__.BentleyError.getErrorMessage(error) + stack;
|
|
18909
|
+
}
|
|
18910
|
+
/**
|
|
18911
|
+
* Merged passed metaData with error properties into one LoggingMetaData, with the passed metaData taking precedence in case of conflict.
|
|
18912
|
+
* @param error The error to be logged as metadata
|
|
18913
|
+
* @param metaData Optional metadata to be merged with the error
|
|
18914
|
+
* @returns A function returning the merged metadata
|
|
18915
|
+
*/
|
|
18916
|
+
static getExceptionMetaData(error, metaData) {
|
|
18917
|
+
const exceptionType = error?.constructor?.name ?? "<Unknown>";
|
|
18918
|
+
if (metaData === undefined) {
|
|
18919
|
+
return () => ({ exceptionType, ...error });
|
|
18892
18920
|
}
|
|
18893
|
-
|
|
18894
|
-
return _BentleyError__WEBPACK_IMPORTED_MODULE_1__.BentleyError.getErrorMessage(err) + stack;
|
|
18921
|
+
return () => ({ exceptionType, ...error, ..._BentleyError__WEBPACK_IMPORTED_MODULE_1__.BentleyError.getMetaData(metaData) });
|
|
18895
18922
|
}
|
|
18896
18923
|
/** Log the specified exception.
|
|
18897
18924
|
* For legacy [[BentleyError]] exceptions, the special "exceptionType" property will be added as metadata. Otherwise, all enumerable members of the exception are logged as metadata.
|
|
18898
18925
|
* @param category The category of the message.
|
|
18899
18926
|
* @param err The exception object.
|
|
18900
18927
|
* @param log The logger output function to use - defaults to Logger.logError
|
|
18928
|
+
* @deprecated in 5.6. Use logError(category, error, metaData) instead, which will log exceptions in the same way but is more flexible and easier to use.
|
|
18901
18929
|
*/
|
|
18902
18930
|
static logException(category, err, log = (_category, message, metaData) => Logger.logError(_category, message, metaData)) {
|
|
18903
18931
|
log(category, Logger.getExceptionMessage(err), () => {
|
|
@@ -21274,7 +21302,7 @@ class UnexpectedErrors {
|
|
|
21274
21302
|
/** handler for logging exception to console */
|
|
21275
21303
|
static consoleLog = (e) => console.error(e); // eslint-disable-line no-console
|
|
21276
21304
|
/** handler for logging exception with [[Logger]] */
|
|
21277
|
-
static errorLog = (e) => _Logger__WEBPACK_IMPORTED_MODULE_0__.Logger.
|
|
21305
|
+
static errorLog = (e) => _Logger__WEBPACK_IMPORTED_MODULE_0__.Logger.logError("unhandled", e);
|
|
21278
21306
|
static _telemetry = [];
|
|
21279
21307
|
static _handler = this.errorLog; // default to error logging
|
|
21280
21308
|
constructor() { } // this is a singleton
|