ITwinError Namespace

Function

Name Description
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

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.  
message string explanation of what went wrong.  
LoggingMetaData | undefined metadata about the exception.  
namespace string namespace for the error.  
stack string | undefined stack trace of the error.  

Defined in

Last Updated: 17 December, 2024