@itwin/core-i18n 5.0.0-dev.92 → 5.0.0-dev.94
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.
|
@@ -15300,11 +15300,13 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
15300
15300
|
/* harmony export */ HttpStatus: () => (/* binding */ HttpStatus),
|
|
15301
15301
|
/* harmony export */ IModelHubStatus: () => (/* binding */ IModelHubStatus),
|
|
15302
15302
|
/* harmony export */ IModelStatus: () => (/* binding */ IModelStatus),
|
|
15303
|
+
/* harmony export */ ITwinError: () => (/* binding */ ITwinError),
|
|
15303
15304
|
/* harmony export */ RealityDataStatus: () => (/* binding */ RealityDataStatus),
|
|
15304
15305
|
/* harmony export */ RpcInterfaceStatus: () => (/* binding */ RpcInterfaceStatus)
|
|
15305
15306
|
/* harmony export */ });
|
|
15306
15307
|
/* harmony import */ var _BeSQLite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BeSQLite */ "../bentley/lib/esm/BeSQLite.js");
|
|
15307
15308
|
/* harmony import */ var _internal_RepositoryStatus__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./internal/RepositoryStatus */ "../bentley/lib/esm/internal/RepositoryStatus.js");
|
|
15309
|
+
/* harmony import */ var _JsonUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./JsonUtils */ "../bentley/lib/esm/JsonUtils.js");
|
|
15308
15310
|
/*---------------------------------------------------------------------------------------------
|
|
15309
15311
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
15310
15312
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -15314,6 +15316,41 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
15314
15316
|
*/
|
|
15315
15317
|
|
|
15316
15318
|
|
|
15319
|
+
|
|
15320
|
+
/** @beta */
|
|
15321
|
+
var ITwinError;
|
|
15322
|
+
(function (ITwinError) {
|
|
15323
|
+
/** Instantiate a new `ITwinError` or subtype thereof.
|
|
15324
|
+
* @see [[ITwinError.throwError]] to conveniently instantiate and throw the error.
|
|
15325
|
+
*/
|
|
15326
|
+
function create(args) {
|
|
15327
|
+
const err = new Error(args.message);
|
|
15328
|
+
Object.assign(err, args);
|
|
15329
|
+
err.name = args.iTwinErrorId.key; // helpful because this is used by `toString` for Error class
|
|
15330
|
+
return err;
|
|
15331
|
+
}
|
|
15332
|
+
ITwinError.create = create;
|
|
15333
|
+
/** Instantiate and immediately throw an `ITwinError`.
|
|
15334
|
+
* @see [[ITwinError.create]] to instantiate an error without throwing it.
|
|
15335
|
+
*/
|
|
15336
|
+
function throwError(args) {
|
|
15337
|
+
throw create(args);
|
|
15338
|
+
}
|
|
15339
|
+
ITwinError.throwError = throwError;
|
|
15340
|
+
/**
|
|
15341
|
+
* Determine whether an error object was thrown by iTwin.js and has a specific scope and key.
|
|
15342
|
+
*
|
|
15343
|
+
* If the test succeeds, the type of `error` is coerced to `T`
|
|
15344
|
+
* @param error The error to ve verified.
|
|
15345
|
+
* @param scope value for `error.iTwinErrorId.scope`
|
|
15346
|
+
* @param key value for `error.iTwinErrorId.key`
|
|
15347
|
+
*/
|
|
15348
|
+
function isError(error, scope, key) {
|
|
15349
|
+
return _JsonUtils__WEBPACK_IMPORTED_MODULE_2__.JsonUtils.isObject(error) && "iTwinErrorId" in error && _JsonUtils__WEBPACK_IMPORTED_MODULE_2__.JsonUtils.isObject(error.iTwinErrorId)
|
|
15350
|
+
&& error.iTwinErrorId.scope === scope && (undefined === key || error.iTwinErrorId.key === key);
|
|
15351
|
+
}
|
|
15352
|
+
ITwinError.isError = isError;
|
|
15353
|
+
})(ITwinError || (ITwinError = {}));
|
|
15317
15354
|
/** Standard status code.
|
|
15318
15355
|
* This status code should be rarely used.
|
|
15319
15356
|
* Prefer to throw an exception to indicate an error, rather than returning a special status code.
|
|
@@ -15603,14 +15640,14 @@ var RealityDataStatus;
|
|
|
15603
15640
|
RealityDataStatus[RealityDataStatus["REALITYDATA_ERROR_BASE"] = 151552] = "REALITYDATA_ERROR_BASE";
|
|
15604
15641
|
RealityDataStatus[RealityDataStatus["InvalidData"] = 151553] = "InvalidData";
|
|
15605
15642
|
})(RealityDataStatus || (RealityDataStatus = {}));
|
|
15606
|
-
|
|
15607
|
-
|
|
15608
|
-
|
|
15609
|
-
/** Base exception class for iTwin.js exceptions.
|
|
15643
|
+
/**
|
|
15644
|
+
* Base exception class for legacy iTwin.js errors.
|
|
15645
|
+
* For backwards compatibility only. Do not create new subclasses of BentleyError. Instead use [[ITwinError]].
|
|
15610
15646
|
* @public
|
|
15611
15647
|
*/
|
|
15612
15648
|
class BentleyError extends Error {
|
|
15613
15649
|
errorNumber;
|
|
15650
|
+
static iTwinErrorScope = "bentley-error";
|
|
15614
15651
|
_metaData;
|
|
15615
15652
|
/**
|
|
15616
15653
|
* @param errorNumber The a number that identifies of the problem.
|
|
@@ -15624,6 +15661,23 @@ class BentleyError extends Error {
|
|
|
15624
15661
|
this._metaData = metaData;
|
|
15625
15662
|
this.name = this._initName();
|
|
15626
15663
|
}
|
|
15664
|
+
/** supply the value for iTwinErrorId */
|
|
15665
|
+
get iTwinErrorId() {
|
|
15666
|
+
return { scope: BentleyError.iTwinErrorScope, key: this.name };
|
|
15667
|
+
}
|
|
15668
|
+
/** value for logging metadata */
|
|
15669
|
+
get loggingMetadata() { return this.getMetaData(); }
|
|
15670
|
+
/**
|
|
15671
|
+
* Determine if an error object implements the `LegacyITwinErrorWithNumber` interface.
|
|
15672
|
+
*
|
|
15673
|
+
* If the test succeeds, the type of `error` is coerced to `T`
|
|
15674
|
+
* @note this method does *not* test that the object is an `instanceOf BentleyError`.
|
|
15675
|
+
* @beta
|
|
15676
|
+
*/
|
|
15677
|
+
static isError(error, errorNumber) {
|
|
15678
|
+
return ITwinError.isError(error, BentleyError.iTwinErrorScope) &&
|
|
15679
|
+
typeof error.errorNumber === "number" && (errorNumber === undefined || error.errorNumber === errorNumber);
|
|
15680
|
+
}
|
|
15627
15681
|
/** Returns true if this BentleyError includes (optional) metadata. */
|
|
15628
15682
|
get hasMetaData() { return undefined !== this._metaData; }
|
|
15629
15683
|
/** get the meta data associated with this BentleyError, if any. */
|
|
@@ -15636,7 +15690,11 @@ class BentleyError extends Error {
|
|
|
15636
15690
|
}
|
|
15637
15691
|
/** This function returns the name of each error status. Override this method to handle more error status codes. */
|
|
15638
15692
|
_initName() {
|
|
15639
|
-
|
|
15693
|
+
return BentleyError.getErrorKey(this.errorNumber);
|
|
15694
|
+
}
|
|
15695
|
+
/** This function returns the name of each error status. */
|
|
15696
|
+
static getErrorKey(errorNumber) {
|
|
15697
|
+
switch (errorNumber) {
|
|
15640
15698
|
case IModelStatus.AlreadyLoaded: return "Already Loaded";
|
|
15641
15699
|
case IModelStatus.AlreadyOpen: return "Already Open";
|
|
15642
15700
|
case IModelStatus.BadArg: return "Bad Arg";
|
|
@@ -15911,7 +15969,7 @@ class BentleyError extends Error {
|
|
|
15911
15969
|
case BentleyStatus.SUCCESS:
|
|
15912
15970
|
return "Success";
|
|
15913
15971
|
default:
|
|
15914
|
-
return `Error (${
|
|
15972
|
+
return `Error (${errorNumber})`;
|
|
15915
15973
|
}
|
|
15916
15974
|
}
|
|
15917
15975
|
/** Use run-time type checking to safely get a useful string summary of an unknown error value, or `""` if none exists.
|
|
@@ -15923,7 +15981,7 @@ class BentleyError extends Error {
|
|
|
15923
15981
|
return error;
|
|
15924
15982
|
if (error instanceof Error)
|
|
15925
15983
|
return error.toString();
|
|
15926
|
-
if (isObject(error)) {
|
|
15984
|
+
if (_JsonUtils__WEBPACK_IMPORTED_MODULE_2__.JsonUtils.isObject(error)) {
|
|
15927
15985
|
if (typeof error.message === "string")
|
|
15928
15986
|
return error.message;
|
|
15929
15987
|
if (typeof error.msg === "string")
|
|
@@ -15939,7 +15997,7 @@ class BentleyError extends Error {
|
|
|
15939
15997
|
* @public
|
|
15940
15998
|
*/
|
|
15941
15999
|
static getErrorStack(error) {
|
|
15942
|
-
if (isObject(error) && typeof error.stack === "string")
|
|
16000
|
+
if (_JsonUtils__WEBPACK_IMPORTED_MODULE_2__.JsonUtils.isObject(error) && typeof error.stack === "string")
|
|
15943
16001
|
return error.stack;
|
|
15944
16002
|
return undefined;
|
|
15945
16003
|
}
|
|
@@ -15949,7 +16007,7 @@ class BentleyError extends Error {
|
|
|
15949
16007
|
* @public
|
|
15950
16008
|
*/
|
|
15951
16009
|
static getErrorMetadata(error) {
|
|
15952
|
-
if (isObject(error) && typeof error.getMetaData === "function") {
|
|
16010
|
+
if (_JsonUtils__WEBPACK_IMPORTED_MODULE_2__.JsonUtils.isObject(error) && typeof error.getMetaData === "function") {
|
|
15953
16011
|
const metadata = error.getMetaData();
|
|
15954
16012
|
if (typeof metadata === "object" && metadata !== null)
|
|
15955
16013
|
return metadata;
|
|
@@ -18113,12 +18171,17 @@ var JsonUtils;
|
|
|
18113
18171
|
json[key] = val;
|
|
18114
18172
|
}
|
|
18115
18173
|
JsonUtils.setOrRemoveBoolean = setOrRemoveBoolean;
|
|
18174
|
+
/** Returns `true` if `json` is a non-null object. */
|
|
18175
|
+
function isObject(json) {
|
|
18176
|
+
return json !== null && "object" === typeof json;
|
|
18177
|
+
}
|
|
18178
|
+
JsonUtils.isObject = isObject;
|
|
18116
18179
|
/** Determine if a Javascript object is equivalent to `{}`.
|
|
18117
18180
|
* @param json The JSON object to test.
|
|
18118
18181
|
* @returns true if `json` is an Object with no keys.
|
|
18119
18182
|
*/
|
|
18120
18183
|
function isEmptyObject(json) {
|
|
18121
|
-
return
|
|
18184
|
+
return isObject(json) && 0 === Object.keys(json).length;
|
|
18122
18185
|
}
|
|
18123
18186
|
JsonUtils.isEmptyObject = isEmptyObject;
|
|
18124
18187
|
/** Determine if the input is undefined or an empty Javascript object.
|
|
@@ -18762,14 +18825,19 @@ class Logger {
|
|
|
18762
18825
|
const stack = Logger.logExceptionCallstacks ? `\n${_BentleyError__WEBPACK_IMPORTED_MODULE_1__.BentleyError.getErrorStack(err)}` : "";
|
|
18763
18826
|
return _BentleyError__WEBPACK_IMPORTED_MODULE_1__.BentleyError.getErrorMessage(err) + stack;
|
|
18764
18827
|
}
|
|
18765
|
-
/** Log the specified exception.
|
|
18828
|
+
/** Log the specified exception.
|
|
18829
|
+
* For legacy [[BentleyError]] exceptions, the special "exceptionType" property will be added as metadata. Otherwise, all enumerable members of the exception are logged as metadata.
|
|
18766
18830
|
* @param category The category of the message.
|
|
18767
18831
|
* @param err The exception object.
|
|
18768
18832
|
* @param log The logger output function to use - defaults to Logger.logError
|
|
18769
18833
|
*/
|
|
18770
18834
|
static logException(category, err, log = (_category, message, metaData) => Logger.logError(_category, message, metaData)) {
|
|
18771
18835
|
log(category, Logger.getExceptionMessage(err), () => {
|
|
18772
|
-
|
|
18836
|
+
// For backwards compatibility, log BentleyError old way
|
|
18837
|
+
if (_BentleyError__WEBPACK_IMPORTED_MODULE_1__.BentleyError.isError(err))
|
|
18838
|
+
return { ..._BentleyError__WEBPACK_IMPORTED_MODULE_1__.BentleyError.getErrorMetadata(err), exceptionType: err?.constructor?.name ?? "<Unknown>" };
|
|
18839
|
+
// return a copy of the error, with non-enumerable members `message` and `stack` removed, as "metadata" for log.
|
|
18840
|
+
return { ...err };
|
|
18773
18841
|
});
|
|
18774
18842
|
}
|
|
18775
18843
|
/** Log the specified message to the **warning** stream.
|
|
@@ -21288,6 +21356,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
21288
21356
|
/* harmony export */ HttpStatus: () => (/* reexport safe */ _BentleyError__WEBPACK_IMPORTED_MODULE_3__.HttpStatus),
|
|
21289
21357
|
/* harmony export */ IModelHubStatus: () => (/* reexport safe */ _BentleyError__WEBPACK_IMPORTED_MODULE_3__.IModelHubStatus),
|
|
21290
21358
|
/* harmony export */ IModelStatus: () => (/* reexport safe */ _BentleyError__WEBPACK_IMPORTED_MODULE_3__.IModelStatus),
|
|
21359
|
+
/* harmony export */ ITwinError: () => (/* reexport safe */ _BentleyError__WEBPACK_IMPORTED_MODULE_3__.ITwinError),
|
|
21291
21360
|
/* harmony export */ Id64: () => (/* reexport safe */ _Id__WEBPACK_IMPORTED_MODULE_13__.Id64),
|
|
21292
21361
|
/* harmony export */ IndexMap: () => (/* reexport safe */ _IndexMap__WEBPACK_IMPORTED_MODULE_14__.IndexMap),
|
|
21293
21362
|
/* harmony export */ IndexedValue: () => (/* reexport safe */ _IndexMap__WEBPACK_IMPORTED_MODULE_14__.IndexedValue),
|