@itwin/core-i18n 5.0.0-dev.93 → 5.0.0-dev.95
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.
|
@@ -17778,11 +17778,13 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
17778
17778
|
/* harmony export */ HttpStatus: () => (/* binding */ HttpStatus),
|
|
17779
17779
|
/* harmony export */ IModelHubStatus: () => (/* binding */ IModelHubStatus),
|
|
17780
17780
|
/* harmony export */ IModelStatus: () => (/* binding */ IModelStatus),
|
|
17781
|
+
/* harmony export */ ITwinError: () => (/* binding */ ITwinError),
|
|
17781
17782
|
/* harmony export */ RealityDataStatus: () => (/* binding */ RealityDataStatus),
|
|
17782
17783
|
/* harmony export */ RpcInterfaceStatus: () => (/* binding */ RpcInterfaceStatus)
|
|
17783
17784
|
/* harmony export */ });
|
|
17784
17785
|
/* harmony import */ var _BeSQLite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BeSQLite */ "../bentley/lib/esm/BeSQLite.js");
|
|
17785
17786
|
/* harmony import */ var _internal_RepositoryStatus__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./internal/RepositoryStatus */ "../bentley/lib/esm/internal/RepositoryStatus.js");
|
|
17787
|
+
/* harmony import */ var _JsonUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./JsonUtils */ "../bentley/lib/esm/JsonUtils.js");
|
|
17786
17788
|
/*---------------------------------------------------------------------------------------------
|
|
17787
17789
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
17788
17790
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -17792,6 +17794,41 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
17792
17794
|
*/
|
|
17793
17795
|
|
|
17794
17796
|
|
|
17797
|
+
|
|
17798
|
+
/** @beta */
|
|
17799
|
+
var ITwinError;
|
|
17800
|
+
(function (ITwinError) {
|
|
17801
|
+
/** Instantiate a new `ITwinError` or subtype thereof.
|
|
17802
|
+
* @see [[ITwinError.throwError]] to conveniently instantiate and throw the error.
|
|
17803
|
+
*/
|
|
17804
|
+
function create(args) {
|
|
17805
|
+
const err = new Error(args.message);
|
|
17806
|
+
Object.assign(err, args);
|
|
17807
|
+
err.name = args.iTwinErrorId.key; // helpful because this is used by `toString` for Error class
|
|
17808
|
+
return err;
|
|
17809
|
+
}
|
|
17810
|
+
ITwinError.create = create;
|
|
17811
|
+
/** Instantiate and immediately throw an `ITwinError`.
|
|
17812
|
+
* @see [[ITwinError.create]] to instantiate an error without throwing it.
|
|
17813
|
+
*/
|
|
17814
|
+
function throwError(args) {
|
|
17815
|
+
throw create(args);
|
|
17816
|
+
}
|
|
17817
|
+
ITwinError.throwError = throwError;
|
|
17818
|
+
/**
|
|
17819
|
+
* Determine whether an error object was thrown by iTwin.js and has a specific scope and key.
|
|
17820
|
+
*
|
|
17821
|
+
* If the test succeeds, the type of `error` is coerced to `T`
|
|
17822
|
+
* @param error The error to ve verified.
|
|
17823
|
+
* @param scope value for `error.iTwinErrorId.scope`
|
|
17824
|
+
* @param key value for `error.iTwinErrorId.key`
|
|
17825
|
+
*/
|
|
17826
|
+
function isError(error, scope, key) {
|
|
17827
|
+
return _JsonUtils__WEBPACK_IMPORTED_MODULE_2__.JsonUtils.isObject(error) && "iTwinErrorId" in error && _JsonUtils__WEBPACK_IMPORTED_MODULE_2__.JsonUtils.isObject(error.iTwinErrorId)
|
|
17828
|
+
&& error.iTwinErrorId.scope === scope && (undefined === key || error.iTwinErrorId.key === key);
|
|
17829
|
+
}
|
|
17830
|
+
ITwinError.isError = isError;
|
|
17831
|
+
})(ITwinError || (ITwinError = {}));
|
|
17795
17832
|
/** Standard status code.
|
|
17796
17833
|
* This status code should be rarely used.
|
|
17797
17834
|
* Prefer to throw an exception to indicate an error, rather than returning a special status code.
|
|
@@ -18081,14 +18118,14 @@ var RealityDataStatus;
|
|
|
18081
18118
|
RealityDataStatus[RealityDataStatus["REALITYDATA_ERROR_BASE"] = 151552] = "REALITYDATA_ERROR_BASE";
|
|
18082
18119
|
RealityDataStatus[RealityDataStatus["InvalidData"] = 151553] = "InvalidData";
|
|
18083
18120
|
})(RealityDataStatus || (RealityDataStatus = {}));
|
|
18084
|
-
|
|
18085
|
-
|
|
18086
|
-
|
|
18087
|
-
/** Base exception class for iTwin.js exceptions.
|
|
18121
|
+
/**
|
|
18122
|
+
* Base exception class for legacy iTwin.js errors.
|
|
18123
|
+
* For backwards compatibility only. Do not create new subclasses of BentleyError. Instead use [[ITwinError]].
|
|
18088
18124
|
* @public
|
|
18089
18125
|
*/
|
|
18090
18126
|
class BentleyError extends Error {
|
|
18091
18127
|
errorNumber;
|
|
18128
|
+
static iTwinErrorScope = "bentley-error";
|
|
18092
18129
|
_metaData;
|
|
18093
18130
|
/**
|
|
18094
18131
|
* @param errorNumber The a number that identifies of the problem.
|
|
@@ -18102,6 +18139,23 @@ class BentleyError extends Error {
|
|
|
18102
18139
|
this._metaData = metaData;
|
|
18103
18140
|
this.name = this._initName();
|
|
18104
18141
|
}
|
|
18142
|
+
/** supply the value for iTwinErrorId */
|
|
18143
|
+
get iTwinErrorId() {
|
|
18144
|
+
return { scope: BentleyError.iTwinErrorScope, key: this.name };
|
|
18145
|
+
}
|
|
18146
|
+
/** value for logging metadata */
|
|
18147
|
+
get loggingMetadata() { return this.getMetaData(); }
|
|
18148
|
+
/**
|
|
18149
|
+
* Determine if an error object implements the `LegacyITwinErrorWithNumber` interface.
|
|
18150
|
+
*
|
|
18151
|
+
* If the test succeeds, the type of `error` is coerced to `T`
|
|
18152
|
+
* @note this method does *not* test that the object is an `instanceOf BentleyError`.
|
|
18153
|
+
* @beta
|
|
18154
|
+
*/
|
|
18155
|
+
static isError(error, errorNumber) {
|
|
18156
|
+
return ITwinError.isError(error, BentleyError.iTwinErrorScope) &&
|
|
18157
|
+
typeof error.errorNumber === "number" && (errorNumber === undefined || error.errorNumber === errorNumber);
|
|
18158
|
+
}
|
|
18105
18159
|
/** Returns true if this BentleyError includes (optional) metadata. */
|
|
18106
18160
|
get hasMetaData() { return undefined !== this._metaData; }
|
|
18107
18161
|
/** get the meta data associated with this BentleyError, if any. */
|
|
@@ -18114,7 +18168,11 @@ class BentleyError extends Error {
|
|
|
18114
18168
|
}
|
|
18115
18169
|
/** This function returns the name of each error status. Override this method to handle more error status codes. */
|
|
18116
18170
|
_initName() {
|
|
18117
|
-
|
|
18171
|
+
return BentleyError.getErrorKey(this.errorNumber);
|
|
18172
|
+
}
|
|
18173
|
+
/** This function returns the name of each error status. */
|
|
18174
|
+
static getErrorKey(errorNumber) {
|
|
18175
|
+
switch (errorNumber) {
|
|
18118
18176
|
case IModelStatus.AlreadyLoaded: return "Already Loaded";
|
|
18119
18177
|
case IModelStatus.AlreadyOpen: return "Already Open";
|
|
18120
18178
|
case IModelStatus.BadArg: return "Bad Arg";
|
|
@@ -18389,7 +18447,7 @@ class BentleyError extends Error {
|
|
|
18389
18447
|
case BentleyStatus.SUCCESS:
|
|
18390
18448
|
return "Success";
|
|
18391
18449
|
default:
|
|
18392
|
-
return `Error (${
|
|
18450
|
+
return `Error (${errorNumber})`;
|
|
18393
18451
|
}
|
|
18394
18452
|
}
|
|
18395
18453
|
/** Use run-time type checking to safely get a useful string summary of an unknown error value, or `""` if none exists.
|
|
@@ -18401,7 +18459,7 @@ class BentleyError extends Error {
|
|
|
18401
18459
|
return error;
|
|
18402
18460
|
if (error instanceof Error)
|
|
18403
18461
|
return error.toString();
|
|
18404
|
-
if (isObject(error)) {
|
|
18462
|
+
if (_JsonUtils__WEBPACK_IMPORTED_MODULE_2__.JsonUtils.isObject(error)) {
|
|
18405
18463
|
if (typeof error.message === "string")
|
|
18406
18464
|
return error.message;
|
|
18407
18465
|
if (typeof error.msg === "string")
|
|
@@ -18417,7 +18475,7 @@ class BentleyError extends Error {
|
|
|
18417
18475
|
* @public
|
|
18418
18476
|
*/
|
|
18419
18477
|
static getErrorStack(error) {
|
|
18420
|
-
if (isObject(error) && typeof error.stack === "string")
|
|
18478
|
+
if (_JsonUtils__WEBPACK_IMPORTED_MODULE_2__.JsonUtils.isObject(error) && typeof error.stack === "string")
|
|
18421
18479
|
return error.stack;
|
|
18422
18480
|
return undefined;
|
|
18423
18481
|
}
|
|
@@ -18427,7 +18485,7 @@ class BentleyError extends Error {
|
|
|
18427
18485
|
* @public
|
|
18428
18486
|
*/
|
|
18429
18487
|
static getErrorMetadata(error) {
|
|
18430
|
-
if (isObject(error) && typeof error.getMetaData === "function") {
|
|
18488
|
+
if (_JsonUtils__WEBPACK_IMPORTED_MODULE_2__.JsonUtils.isObject(error) && typeof error.getMetaData === "function") {
|
|
18431
18489
|
const metadata = error.getMetaData();
|
|
18432
18490
|
if (typeof metadata === "object" && metadata !== null)
|
|
18433
18491
|
return metadata;
|
|
@@ -20591,12 +20649,17 @@ var JsonUtils;
|
|
|
20591
20649
|
json[key] = val;
|
|
20592
20650
|
}
|
|
20593
20651
|
JsonUtils.setOrRemoveBoolean = setOrRemoveBoolean;
|
|
20652
|
+
/** Returns `true` if `json` is a non-null object. */
|
|
20653
|
+
function isObject(json) {
|
|
20654
|
+
return json !== null && "object" === typeof json;
|
|
20655
|
+
}
|
|
20656
|
+
JsonUtils.isObject = isObject;
|
|
20594
20657
|
/** Determine if a Javascript object is equivalent to `{}`.
|
|
20595
20658
|
* @param json The JSON object to test.
|
|
20596
20659
|
* @returns true if `json` is an Object with no keys.
|
|
20597
20660
|
*/
|
|
20598
20661
|
function isEmptyObject(json) {
|
|
20599
|
-
return
|
|
20662
|
+
return isObject(json) && 0 === Object.keys(json).length;
|
|
20600
20663
|
}
|
|
20601
20664
|
JsonUtils.isEmptyObject = isEmptyObject;
|
|
20602
20665
|
/** Determine if the input is undefined or an empty Javascript object.
|
|
@@ -21240,14 +21303,19 @@ class Logger {
|
|
|
21240
21303
|
const stack = Logger.logExceptionCallstacks ? `\n${_BentleyError__WEBPACK_IMPORTED_MODULE_1__.BentleyError.getErrorStack(err)}` : "";
|
|
21241
21304
|
return _BentleyError__WEBPACK_IMPORTED_MODULE_1__.BentleyError.getErrorMessage(err) + stack;
|
|
21242
21305
|
}
|
|
21243
|
-
/** Log the specified exception.
|
|
21306
|
+
/** Log the specified exception.
|
|
21307
|
+
* For legacy [[BentleyError]] exceptions, the special "exceptionType" property will be added as metadata. Otherwise, all enumerable members of the exception are logged as metadata.
|
|
21244
21308
|
* @param category The category of the message.
|
|
21245
21309
|
* @param err The exception object.
|
|
21246
21310
|
* @param log The logger output function to use - defaults to Logger.logError
|
|
21247
21311
|
*/
|
|
21248
21312
|
static logException(category, err, log = (_category, message, metaData) => Logger.logError(_category, message, metaData)) {
|
|
21249
21313
|
log(category, Logger.getExceptionMessage(err), () => {
|
|
21250
|
-
|
|
21314
|
+
// For backwards compatibility, log BentleyError old way
|
|
21315
|
+
if (_BentleyError__WEBPACK_IMPORTED_MODULE_1__.BentleyError.isError(err))
|
|
21316
|
+
return { ..._BentleyError__WEBPACK_IMPORTED_MODULE_1__.BentleyError.getErrorMetadata(err), exceptionType: err?.constructor?.name ?? "<Unknown>" };
|
|
21317
|
+
// return a copy of the error, with non-enumerable members `message` and `stack` removed, as "metadata" for log.
|
|
21318
|
+
return { ...err };
|
|
21251
21319
|
});
|
|
21252
21320
|
}
|
|
21253
21321
|
/** Log the specified message to the **warning** stream.
|
|
@@ -23766,6 +23834,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
23766
23834
|
/* harmony export */ HttpStatus: () => (/* reexport safe */ _BentleyError__WEBPACK_IMPORTED_MODULE_3__.HttpStatus),
|
|
23767
23835
|
/* harmony export */ IModelHubStatus: () => (/* reexport safe */ _BentleyError__WEBPACK_IMPORTED_MODULE_3__.IModelHubStatus),
|
|
23768
23836
|
/* harmony export */ IModelStatus: () => (/* reexport safe */ _BentleyError__WEBPACK_IMPORTED_MODULE_3__.IModelStatus),
|
|
23837
|
+
/* harmony export */ ITwinError: () => (/* reexport safe */ _BentleyError__WEBPACK_IMPORTED_MODULE_3__.ITwinError),
|
|
23769
23838
|
/* harmony export */ Id64: () => (/* reexport safe */ _Id__WEBPACK_IMPORTED_MODULE_13__.Id64),
|
|
23770
23839
|
/* harmony export */ IndexMap: () => (/* reexport safe */ _IndexMap__WEBPACK_IMPORTED_MODULE_14__.IndexMap),
|
|
23771
23840
|
/* harmony export */ IndexedValue: () => (/* reexport safe */ _IndexMap__WEBPACK_IMPORTED_MODULE_14__.IndexedValue),
|