@itwin/core-bentley 5.0.0-dev.11 → 5.0.0-dev.110
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/CHANGELOG.md +61 -1
- package/lib/cjs/BeEvent.js +3 -7
- package/lib/cjs/BeEvent.js.map +1 -1
- package/lib/cjs/BentleyError.d.ts +83 -1
- package/lib/cjs/BentleyError.d.ts.map +1 -1
- package/lib/cjs/BentleyError.js +72 -11
- package/lib/cjs/BentleyError.js.map +1 -1
- package/lib/cjs/ByteStream.d.ts +3 -22
- package/lib/cjs/ByteStream.d.ts.map +1 -1
- package/lib/cjs/ByteStream.js +7 -21
- package/lib/cjs/ByteStream.js.map +1 -1
- package/lib/cjs/Compare.d.ts +15 -0
- package/lib/cjs/Compare.d.ts.map +1 -1
- package/lib/cjs/Compare.js +48 -0
- package/lib/cjs/Compare.js.map +1 -1
- package/lib/cjs/CompressedId64Set.js +6 -3
- package/lib/cjs/CompressedId64Set.js.map +1 -1
- package/lib/cjs/Dictionary.js +8 -3
- package/lib/cjs/Dictionary.js.map +1 -1
- package/lib/cjs/Disposable.d.ts +18 -0
- package/lib/cjs/Disposable.d.ts.map +1 -1
- package/lib/cjs/Disposable.js +25 -25
- package/lib/cjs/Disposable.js.map +1 -1
- package/lib/cjs/Id.d.ts +0 -4
- package/lib/cjs/Id.d.ts.map +1 -1
- package/lib/cjs/Id.js +9 -11
- package/lib/cjs/Id.js.map +1 -1
- package/lib/cjs/IndexMap.js +6 -1
- package/lib/cjs/IndexMap.js.map +1 -1
- package/lib/cjs/JsonUtils.d.ts +4 -0
- package/lib/cjs/JsonUtils.d.ts.map +1 -1
- package/lib/cjs/JsonUtils.js +6 -1
- package/lib/cjs/JsonUtils.js.map +1 -1
- package/lib/cjs/LRUMap.js +16 -0
- package/lib/cjs/LRUMap.js.map +1 -1
- package/lib/cjs/Logger.d.ts +26 -3
- package/lib/cjs/Logger.d.ts.map +1 -1
- package/lib/cjs/Logger.js +33 -9
- package/lib/cjs/Logger.js.map +1 -1
- package/lib/cjs/ObservableSet.js +6 -6
- package/lib/cjs/ObservableSet.js.map +1 -1
- package/lib/cjs/OneAtATimeAction.js +9 -0
- package/lib/cjs/OneAtATimeAction.js.map +1 -1
- package/lib/cjs/OrderedSet.js +1 -0
- package/lib/cjs/OrderedSet.js.map +1 -1
- package/lib/cjs/PriorityQueue.js +3 -1
- package/lib/cjs/PriorityQueue.js.map +1 -1
- package/lib/cjs/SortedArray.js +4 -1
- package/lib/cjs/SortedArray.js.map +1 -1
- package/lib/cjs/StatusCategory.js +42 -105
- package/lib/cjs/StatusCategory.js.map +1 -1
- package/lib/cjs/Time.js +5 -0
- package/lib/cjs/Time.js.map +1 -1
- package/lib/cjs/Tracing.js +2 -0
- package/lib/cjs/Tracing.js.map +1 -1
- package/lib/cjs/TupleKeyedMap.js +2 -2
- package/lib/cjs/TupleKeyedMap.js.map +1 -1
- package/lib/cjs/TypedArrayBuilder.js +8 -0
- package/lib/cjs/TypedArrayBuilder.js.map +1 -1
- package/lib/cjs/UnexpectedErrors.js +10 -12
- package/lib/cjs/UnexpectedErrors.js.map +1 -1
- package/lib/cjs/YieldManager.js +3 -1
- package/lib/cjs/YieldManager.js.map +1 -1
- package/lib/cjs/internal/cross-package.d.ts +0 -1
- package/lib/cjs/internal/cross-package.d.ts.map +1 -1
- package/lib/cjs/internal/cross-package.js +1 -3
- package/lib/cjs/internal/cross-package.js.map +1 -1
- package/lib/esm/BeEvent.js +3 -7
- package/lib/esm/BeEvent.js.map +1 -1
- package/lib/esm/BentleyError.d.ts +83 -1
- package/lib/esm/BentleyError.d.ts.map +1 -1
- package/lib/esm/BentleyError.js +71 -10
- package/lib/esm/BentleyError.js.map +1 -1
- package/lib/esm/ByteStream.d.ts +3 -22
- package/lib/esm/ByteStream.d.ts.map +1 -1
- package/lib/esm/ByteStream.js +7 -21
- package/lib/esm/ByteStream.js.map +1 -1
- package/lib/esm/Compare.d.ts +15 -0
- package/lib/esm/Compare.d.ts.map +1 -1
- package/lib/esm/Compare.js +46 -0
- package/lib/esm/Compare.js.map +1 -1
- package/lib/esm/CompressedId64Set.js +6 -3
- package/lib/esm/CompressedId64Set.js.map +1 -1
- package/lib/esm/Dictionary.js +8 -3
- package/lib/esm/Dictionary.js.map +1 -1
- package/lib/esm/Disposable.d.ts +18 -0
- package/lib/esm/Disposable.d.ts.map +1 -1
- package/lib/esm/Disposable.js +24 -25
- package/lib/esm/Disposable.js.map +1 -1
- package/lib/esm/Id.d.ts +0 -4
- package/lib/esm/Id.d.ts.map +1 -1
- package/lib/esm/Id.js +9 -11
- package/lib/esm/Id.js.map +1 -1
- package/lib/esm/IndexMap.js +6 -1
- package/lib/esm/IndexMap.js.map +1 -1
- package/lib/esm/JsonUtils.d.ts +4 -0
- package/lib/esm/JsonUtils.d.ts.map +1 -1
- package/lib/esm/JsonUtils.js +6 -1
- package/lib/esm/JsonUtils.js.map +1 -1
- package/lib/esm/LRUMap.js +16 -0
- package/lib/esm/LRUMap.js.map +1 -1
- package/lib/esm/Logger.d.ts +26 -3
- package/lib/esm/Logger.d.ts.map +1 -1
- package/lib/esm/Logger.js +33 -9
- package/lib/esm/Logger.js.map +1 -1
- package/lib/esm/ObservableSet.js +6 -6
- package/lib/esm/ObservableSet.js.map +1 -1
- package/lib/esm/OneAtATimeAction.js +9 -0
- package/lib/esm/OneAtATimeAction.js.map +1 -1
- package/lib/esm/OrderedSet.js +1 -0
- package/lib/esm/OrderedSet.js.map +1 -1
- package/lib/esm/PriorityQueue.js +3 -1
- package/lib/esm/PriorityQueue.js.map +1 -1
- package/lib/esm/SortedArray.js +4 -1
- package/lib/esm/SortedArray.js.map +1 -1
- package/lib/esm/StatusCategory.js +42 -105
- package/lib/esm/StatusCategory.js.map +1 -1
- package/lib/esm/Time.js +5 -0
- package/lib/esm/Time.js.map +1 -1
- package/lib/esm/Tracing.js +2 -0
- package/lib/esm/Tracing.js.map +1 -1
- package/lib/esm/TupleKeyedMap.js +2 -2
- package/lib/esm/TupleKeyedMap.js.map +1 -1
- package/lib/esm/TypedArrayBuilder.js +8 -0
- package/lib/esm/TypedArrayBuilder.js.map +1 -1
- package/lib/esm/UnexpectedErrors.js +10 -12
- package/lib/esm/UnexpectedErrors.js.map +1 -1
- package/lib/esm/YieldManager.js +3 -1
- package/lib/esm/YieldManager.js.map +1 -1
- package/lib/esm/internal/cross-package.d.ts +0 -1
- package/lib/esm/internal/cross-package.d.ts.map +1 -1
- package/lib/esm/internal/cross-package.js +0 -1
- package/lib/esm/internal/cross-package.js.map +1 -1
- package/package.json +8 -8
- package/lib/cjs/internal/staticLoggerMetadata.d.ts +0 -11
- package/lib/cjs/internal/staticLoggerMetadata.d.ts.map +0 -1
- package/lib/cjs/internal/staticLoggerMetadata.js +0 -17
- package/lib/cjs/internal/staticLoggerMetadata.js.map +0 -1
- package/lib/esm/internal/staticLoggerMetadata.d.ts +0 -11
- package/lib/esm/internal/staticLoggerMetadata.d.ts.map +0 -1
- package/lib/esm/internal/staticLoggerMetadata.js +0 -14
- package/lib/esm/internal/staticLoggerMetadata.js.map +0 -1
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module Errors
|
|
3
3
|
*/
|
|
4
|
+
/** Uniquely identifies a specific kind of [[ITwinError]].
|
|
5
|
+
* @beta
|
|
6
|
+
*/
|
|
7
|
+
export interface ITwinErrorId {
|
|
8
|
+
/** A "namespace" serving as a qualifier for the [[key]]. It should be specific enough to ensure uniqueness across all applications.
|
|
9
|
+
* For example, all errors originating from a given package should use that package's full name as their scope.
|
|
10
|
+
*/
|
|
11
|
+
readonly scope: string;
|
|
12
|
+
/** Uniquely identifies a specific kind of [[ITwinError]] within the [[scope]]. */
|
|
13
|
+
readonly key: string;
|
|
14
|
+
}
|
|
15
|
+
/** The interface that all exceptions thrown by iTwin.js libraries and applications should implement.
|
|
16
|
+
* Specific kinds of `ITwinError`s are identified by an [[ITwinErrorId]] that allows programmers to identify errors when they are caught without relying
|
|
17
|
+
* on specific class hierarchies, which is especially important when errors are marshalled across process boundaries.
|
|
18
|
+
* You can extend `ITwinError` to add properties that provide programmers with additional context for a particular kind of error.
|
|
19
|
+
* When catching errors, programmers can use [[isError]] to determine if the error is of a specific sub-type, and if so access the
|
|
20
|
+
* additional properties.
|
|
21
|
+
* Those additional properties will also be logged as metadata by [[Logger.logException]].
|
|
22
|
+
* @beta
|
|
23
|
+
*/
|
|
24
|
+
export interface ITwinError extends Error {
|
|
25
|
+
/** Uniquely identifies the kind of error. */
|
|
26
|
+
readonly iTwinErrorId: ITwinErrorId;
|
|
27
|
+
}
|
|
28
|
+
/** @beta */
|
|
29
|
+
export declare namespace ITwinError {
|
|
30
|
+
/** Instantiate a new `ITwinError` or subtype thereof.
|
|
31
|
+
* @see [[ITwinError.throwError]] to conveniently instantiate and throw the error.
|
|
32
|
+
*/
|
|
33
|
+
function create<T extends ITwinError>(args: Omit<T, "name">): T;
|
|
34
|
+
/** Instantiate and immediately throw an `ITwinError`.
|
|
35
|
+
* @see [[ITwinError.create]] to instantiate an error without throwing it.
|
|
36
|
+
*/
|
|
37
|
+
function throwError<T extends ITwinError>(args: Omit<T, "name">): never;
|
|
38
|
+
/**
|
|
39
|
+
* Determine whether an error object was thrown by iTwin.js and has a specific scope and key.
|
|
40
|
+
*
|
|
41
|
+
* If the test succeeds, the type of `error` is coerced to `T`
|
|
42
|
+
* @param error The error to ve verified.
|
|
43
|
+
* @param scope value for `error.iTwinErrorId.scope`
|
|
44
|
+
* @param key value for `error.iTwinErrorId.key`
|
|
45
|
+
*/
|
|
46
|
+
function isError<T extends ITwinError>(error: unknown, scope: string, key?: string): error is T;
|
|
47
|
+
}
|
|
4
48
|
/** Standard status code.
|
|
5
49
|
* This status code should be rarely used.
|
|
6
50
|
* Prefer to throw an exception to indicate an error, rather than returning a special status code.
|
|
@@ -265,6 +309,9 @@ export declare enum GeoServiceStatus {
|
|
|
265
309
|
NoDatumConverter = 147459,
|
|
266
310
|
VerticalDatumConvertError = 147460,
|
|
267
311
|
CSMapError = 147461,
|
|
312
|
+
/**
|
|
313
|
+
* @deprecated in 5.0. This status is never returned.
|
|
314
|
+
*/
|
|
268
315
|
Pending = 147462
|
|
269
316
|
}
|
|
270
317
|
/** Error status from various reality data operations
|
|
@@ -290,11 +337,29 @@ interface ErrorProps {
|
|
|
290
337
|
stack?: string;
|
|
291
338
|
metadata?: object;
|
|
292
339
|
}
|
|
293
|
-
/**
|
|
340
|
+
/**
|
|
341
|
+
* An [[ITwinError]] that also supplies an `errorNumber`.
|
|
342
|
+
* @note this interface exists *only* for legacy errors derived from `BentleyError`. The concept of "error number" is
|
|
343
|
+
* problematic since it is impossible to enforce across the iTwin.js library, let alone across applications. New code should
|
|
344
|
+
* use `ITwinError` and identify errors with strings instead.
|
|
345
|
+
* @beta */
|
|
346
|
+
export interface LegacyITwinErrorWithNumber extends ITwinError {
|
|
347
|
+
/** a number to identify the error. */
|
|
348
|
+
readonly errorNumber: number;
|
|
349
|
+
/** Logging metadata
|
|
350
|
+
* @note exceptions should *not* include logging data. Logging should be done where exceptions are caught. This member exists
|
|
351
|
+
* only for backwards compatibility.
|
|
352
|
+
*/
|
|
353
|
+
loggingMetadata?: object;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Base exception class for legacy iTwin.js errors.
|
|
357
|
+
* For backwards compatibility only. Do not create new subclasses of BentleyError. Instead use [[ITwinError]].
|
|
294
358
|
* @public
|
|
295
359
|
*/
|
|
296
360
|
export declare class BentleyError extends Error {
|
|
297
361
|
errorNumber: number;
|
|
362
|
+
static readonly iTwinErrorScope = "bentley-error";
|
|
298
363
|
private readonly _metaData;
|
|
299
364
|
/**
|
|
300
365
|
* @param errorNumber The a number that identifies of the problem.
|
|
@@ -302,6 +367,21 @@ export declare class BentleyError extends Error {
|
|
|
302
367
|
* @param metaData metaData about the exception.
|
|
303
368
|
*/
|
|
304
369
|
constructor(errorNumber: number, message?: string, metaData?: LoggingMetaData);
|
|
370
|
+
/** supply the value for iTwinErrorId */
|
|
371
|
+
get iTwinErrorId(): {
|
|
372
|
+
scope: string;
|
|
373
|
+
key: string;
|
|
374
|
+
};
|
|
375
|
+
/** value for logging metadata */
|
|
376
|
+
get loggingMetadata(): object | undefined;
|
|
377
|
+
/**
|
|
378
|
+
* Determine if an error object implements the `LegacyITwinErrorWithNumber` interface.
|
|
379
|
+
*
|
|
380
|
+
* If the test succeeds, the type of `error` is coerced to `T`
|
|
381
|
+
* @note this method does *not* test that the object is an `instanceOf BentleyError`.
|
|
382
|
+
* @beta
|
|
383
|
+
*/
|
|
384
|
+
static isError<T extends LegacyITwinErrorWithNumber>(error: unknown, errorNumber?: number): error is T;
|
|
305
385
|
/** Returns true if this BentleyError includes (optional) metadata. */
|
|
306
386
|
get hasMetaData(): boolean;
|
|
307
387
|
/** get the meta data associated with this BentleyError, if any. */
|
|
@@ -310,6 +390,8 @@ export declare class BentleyError extends Error {
|
|
|
310
390
|
static getMetaData(metaData: LoggingMetaData): object | undefined;
|
|
311
391
|
/** This function returns the name of each error status. Override this method to handle more error status codes. */
|
|
312
392
|
protected _initName(): string;
|
|
393
|
+
/** This function returns the name of each error status. */
|
|
394
|
+
static getErrorKey(errorNumber: number): string;
|
|
313
395
|
/** Use run-time type checking to safely get a useful string summary of an unknown error value, or `""` if none exists.
|
|
314
396
|
* @note It's recommended to use this function in `catch` clauses, where a caught value cannot be assumed to be `instanceof Error`
|
|
315
397
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BentleyError.d.ts","sourceRoot":"","sources":["../../src/BentleyError.ts"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"BentleyError.d.ts","sourceRoot":"","sources":["../../src/BentleyError.ts"],"names":[],"mappings":"AAIA;;GAEG;AAMH;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,kFAAkF;IA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yCAAyC;IACzC,IAAW,YAAY;;;MAEtB;IACD,iCAAiC;IACjC,IAAW,eAAe,uBAAiC;IAE3D;;;;;;OAMG;WACW,OAAO,CAAC,CAAC,SAAS,0BAA0B,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,KAAK,IAAI,CAAC;IAK7G,sEAAsE;IACtE,IAAW,WAAW,IAAI,OAAO,CAAyC;IAE1E,mEAAmE;IAC5D,WAAW,IAAI,MAAM,GAAG,SAAS;IAIxC,4EAA4E;WAC9D,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,GAAG,SAAS;IAIxE,mHAAmH;IACnH,SAAS,CAAC,SAAS,IAAI,MAAM;IAI7B,2DAA2D;WAC7C,WAAW,CAAC,WAAW,EAAE,MAAM;IA0R7C;;;OAGG;WACW,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM;IAsBrD;;;OAGG;WACW,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS;IAO/D;;;;OAIG;WACW,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS;IAUlE;;;;OAIG;WACW,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU;CAexD"}
|
package/lib/esm/BentleyError.js
CHANGED
|
@@ -7,6 +7,41 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { DbResult } from "./BeSQLite";
|
|
9
9
|
import { RepositoryStatus } from "./internal/RepositoryStatus";
|
|
10
|
+
import { JsonUtils } from "./JsonUtils";
|
|
11
|
+
/** @beta */
|
|
12
|
+
export var ITwinError;
|
|
13
|
+
(function (ITwinError) {
|
|
14
|
+
/** Instantiate a new `ITwinError` or subtype thereof.
|
|
15
|
+
* @see [[ITwinError.throwError]] to conveniently instantiate and throw the error.
|
|
16
|
+
*/
|
|
17
|
+
function create(args) {
|
|
18
|
+
const err = new Error(args.message);
|
|
19
|
+
Object.assign(err, args);
|
|
20
|
+
err.name = args.iTwinErrorId.key; // helpful because this is used by `toString` for Error class
|
|
21
|
+
return err;
|
|
22
|
+
}
|
|
23
|
+
ITwinError.create = create;
|
|
24
|
+
/** Instantiate and immediately throw an `ITwinError`.
|
|
25
|
+
* @see [[ITwinError.create]] to instantiate an error without throwing it.
|
|
26
|
+
*/
|
|
27
|
+
function throwError(args) {
|
|
28
|
+
throw create(args);
|
|
29
|
+
}
|
|
30
|
+
ITwinError.throwError = throwError;
|
|
31
|
+
/**
|
|
32
|
+
* Determine whether an error object was thrown by iTwin.js and has a specific scope and key.
|
|
33
|
+
*
|
|
34
|
+
* If the test succeeds, the type of `error` is coerced to `T`
|
|
35
|
+
* @param error The error to ve verified.
|
|
36
|
+
* @param scope value for `error.iTwinErrorId.scope`
|
|
37
|
+
* @param key value for `error.iTwinErrorId.key`
|
|
38
|
+
*/
|
|
39
|
+
function isError(error, scope, key) {
|
|
40
|
+
return JsonUtils.isObject(error) && "iTwinErrorId" in error && JsonUtils.isObject(error.iTwinErrorId)
|
|
41
|
+
&& error.iTwinErrorId.scope === scope && (undefined === key || error.iTwinErrorId.key === key);
|
|
42
|
+
}
|
|
43
|
+
ITwinError.isError = isError;
|
|
44
|
+
})(ITwinError || (ITwinError = {}));
|
|
10
45
|
/** Standard status code.
|
|
11
46
|
* This status code should be rarely used.
|
|
12
47
|
* Prefer to throw an exception to indicate an error, rather than returning a special status code.
|
|
@@ -282,6 +317,9 @@ export var GeoServiceStatus;
|
|
|
282
317
|
GeoServiceStatus[GeoServiceStatus["NoDatumConverter"] = 147459] = "NoDatumConverter";
|
|
283
318
|
GeoServiceStatus[GeoServiceStatus["VerticalDatumConvertError"] = 147460] = "VerticalDatumConvertError";
|
|
284
319
|
GeoServiceStatus[GeoServiceStatus["CSMapError"] = 147461] = "CSMapError";
|
|
320
|
+
/**
|
|
321
|
+
* @deprecated in 5.0. This status is never returned.
|
|
322
|
+
*/
|
|
285
323
|
GeoServiceStatus[GeoServiceStatus["Pending"] = 147462] = "Pending";
|
|
286
324
|
})(GeoServiceStatus || (GeoServiceStatus = {}));
|
|
287
325
|
/** Error status from various reality data operations
|
|
@@ -293,13 +331,15 @@ export var RealityDataStatus;
|
|
|
293
331
|
RealityDataStatus[RealityDataStatus["REALITYDATA_ERROR_BASE"] = 151552] = "REALITYDATA_ERROR_BASE";
|
|
294
332
|
RealityDataStatus[RealityDataStatus["InvalidData"] = 151553] = "InvalidData";
|
|
295
333
|
})(RealityDataStatus || (RealityDataStatus = {}));
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
/** Base exception class for iTwin.js exceptions.
|
|
334
|
+
/**
|
|
335
|
+
* Base exception class for legacy iTwin.js errors.
|
|
336
|
+
* For backwards compatibility only. Do not create new subclasses of BentleyError. Instead use [[ITwinError]].
|
|
300
337
|
* @public
|
|
301
338
|
*/
|
|
302
339
|
export class BentleyError extends Error {
|
|
340
|
+
errorNumber;
|
|
341
|
+
static iTwinErrorScope = "bentley-error";
|
|
342
|
+
_metaData;
|
|
303
343
|
/**
|
|
304
344
|
* @param errorNumber The a number that identifies of the problem.
|
|
305
345
|
* @param message message that describes the problem (should not be localized).
|
|
@@ -312,6 +352,23 @@ export class BentleyError extends Error {
|
|
|
312
352
|
this._metaData = metaData;
|
|
313
353
|
this.name = this._initName();
|
|
314
354
|
}
|
|
355
|
+
/** supply the value for iTwinErrorId */
|
|
356
|
+
get iTwinErrorId() {
|
|
357
|
+
return { scope: BentleyError.iTwinErrorScope, key: this.name };
|
|
358
|
+
}
|
|
359
|
+
/** value for logging metadata */
|
|
360
|
+
get loggingMetadata() { return this.getMetaData(); }
|
|
361
|
+
/**
|
|
362
|
+
* Determine if an error object implements the `LegacyITwinErrorWithNumber` interface.
|
|
363
|
+
*
|
|
364
|
+
* If the test succeeds, the type of `error` is coerced to `T`
|
|
365
|
+
* @note this method does *not* test that the object is an `instanceOf BentleyError`.
|
|
366
|
+
* @beta
|
|
367
|
+
*/
|
|
368
|
+
static isError(error, errorNumber) {
|
|
369
|
+
return ITwinError.isError(error, BentleyError.iTwinErrorScope) &&
|
|
370
|
+
typeof error.errorNumber === "number" && (errorNumber === undefined || error.errorNumber === errorNumber);
|
|
371
|
+
}
|
|
315
372
|
/** Returns true if this BentleyError includes (optional) metadata. */
|
|
316
373
|
get hasMetaData() { return undefined !== this._metaData; }
|
|
317
374
|
/** get the meta data associated with this BentleyError, if any. */
|
|
@@ -324,7 +381,11 @@ export class BentleyError extends Error {
|
|
|
324
381
|
}
|
|
325
382
|
/** This function returns the name of each error status. Override this method to handle more error status codes. */
|
|
326
383
|
_initName() {
|
|
327
|
-
|
|
384
|
+
return BentleyError.getErrorKey(this.errorNumber);
|
|
385
|
+
}
|
|
386
|
+
/** This function returns the name of each error status. */
|
|
387
|
+
static getErrorKey(errorNumber) {
|
|
388
|
+
switch (errorNumber) {
|
|
328
389
|
case IModelStatus.AlreadyLoaded: return "Already Loaded";
|
|
329
390
|
case IModelStatus.AlreadyOpen: return "Already Open";
|
|
330
391
|
case IModelStatus.BadArg: return "Bad Arg";
|
|
@@ -591,7 +652,7 @@ export class BentleyError extends Error {
|
|
|
591
652
|
case GeoServiceStatus.NoDatumConverter: return "No datum converter";
|
|
592
653
|
case GeoServiceStatus.VerticalDatumConvertError: return "Vertical datum convert error";
|
|
593
654
|
case GeoServiceStatus.CSMapError: return "CSMap error";
|
|
594
|
-
case GeoServiceStatus.Pending: return "Pending";
|
|
655
|
+
case GeoServiceStatus.Pending: return "Pending"; // eslint-disable-line @typescript-eslint/no-deprecated
|
|
595
656
|
case RealityDataStatus.InvalidData: return "Invalid or unknown data";
|
|
596
657
|
case DbResult.BE_SQLITE_OK:
|
|
597
658
|
case DbResult.BE_SQLITE_ROW:
|
|
@@ -599,7 +660,7 @@ export class BentleyError extends Error {
|
|
|
599
660
|
case BentleyStatus.SUCCESS:
|
|
600
661
|
return "Success";
|
|
601
662
|
default:
|
|
602
|
-
return `Error (${
|
|
663
|
+
return `Error (${errorNumber})`;
|
|
603
664
|
}
|
|
604
665
|
}
|
|
605
666
|
/** Use run-time type checking to safely get a useful string summary of an unknown error value, or `""` if none exists.
|
|
@@ -611,7 +672,7 @@ export class BentleyError extends Error {
|
|
|
611
672
|
return error;
|
|
612
673
|
if (error instanceof Error)
|
|
613
674
|
return error.toString();
|
|
614
|
-
if (isObject(error)) {
|
|
675
|
+
if (JsonUtils.isObject(error)) {
|
|
615
676
|
if (typeof error.message === "string")
|
|
616
677
|
return error.message;
|
|
617
678
|
if (typeof error.msg === "string")
|
|
@@ -627,7 +688,7 @@ export class BentleyError extends Error {
|
|
|
627
688
|
* @public
|
|
628
689
|
*/
|
|
629
690
|
static getErrorStack(error) {
|
|
630
|
-
if (isObject(error) && typeof error.stack === "string")
|
|
691
|
+
if (JsonUtils.isObject(error) && typeof error.stack === "string")
|
|
631
692
|
return error.stack;
|
|
632
693
|
return undefined;
|
|
633
694
|
}
|
|
@@ -637,7 +698,7 @@ export class BentleyError extends Error {
|
|
|
637
698
|
* @public
|
|
638
699
|
*/
|
|
639
700
|
static getErrorMetadata(error) {
|
|
640
|
-
if (isObject(error) && typeof error.getMetaData === "function") {
|
|
701
|
+
if (JsonUtils.isObject(error) && typeof error.getMetaData === "function") {
|
|
641
702
|
const metadata = error.getMetaData();
|
|
642
703
|
if (typeof metadata === "object" && metadata !== null)
|
|
643
704
|
return metadata;
|