ITwinError Namespace
Function
Name | Description |
---|---|
ITwinError.getMetaData | get the meta data associated with this ITwinError, if any. |
ITwinError.isITwinError | type guard function that returns whether or not the passed in parameter is an ITwinError |
Defined in
- core/common/src/ITwinError.ts Line 40
ITwinError Interface
An interface used to describe an error for a developer/application. The message is not intended to be displayed to an end user. This error interface should be extended when needing to throw errors with extra properties defined on them. See InUseLocksError for an example. When extending ITwinError, one should typically add a type guard function and a function to throw the error either to a namespace for their error or as standalone functions. See throwInUseLocksError and isInUseLocksError for examples of how to throw and check that an error is of type InUseLocksError.
- Example of catching a ITwinError:
try { await briefcaseDb.locks.acquireLocks({ exclusive: elementId }); } catch (err) { if (InUseLocksError.isInUseLocksError(err)) { const inUseLocks = err.inUseLocks; for (const inUseLock of inUseLocks) { const _briefcaseIds = inUseLock.briefcaseIds; const _state = inUseLock.state; const _objectId = inUseLock.objectId; // Create a user friendly error message } } else { throw err; }
Properties
Name | Type | Description | |
---|---|---|---|
errorKey | string | unique key for error, within namespace. | |
string | explanation of what went wrong. | ||
metadata | LoggingMetaData | undefined | metadata about the exception. | |
namespace | string | namespace for the error. | |
stack | string | undefined | stack trace of the error. |
Defined in
- core/common/src/ITwinError.ts Line 40
Last Updated: 14 November, 2024
Found something wrong, missing, or unclear on this page?Raise an issue in our repo.