UNPKG

@itwin/core-common

Version:

iTwin.js components common to frontend and backend

87 lines 3.71 kB
"use strict"; /*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ /** @packageDocumentation * @module iModels */ Object.defineProperty(exports, "__esModule", { value: true }); exports.NoContentError = exports.BackendError = exports.ServerTimeoutError = exports.ServerError = exports.ConflictingLocksError = exports.LockState = exports.IModelError = void 0; const core_bentley_1 = require("@itwin/core-bentley"); /** The error type thrown by this module. * @see [[ITwinError]] * @see [[IModelErrorNumber]] for commonly-used error codes. * @public */ class IModelError extends core_bentley_1.BentleyError { constructor(errorNumber, message, getMetaData) { super(errorNumber, message, getMetaData); } } exports.IModelError = IModelError; /** The state of a lock. See [Acquiring locks on elements.]($docs/learning/backend/ConcurrencyControl.md#acquiring-locks-on-elements). * @public */ var LockState; (function (LockState) { /** The element is not locked */ LockState[LockState["None"] = 0] = "None"; /** Holding a shared lock on an element blocks other users from acquiring the Exclusive lock it. More than one user may acquire the shared lock. */ LockState[LockState["Shared"] = 1] = "Shared"; /** A Lock that permits modifications to an element and blocks other users from making modifications to it. * Holding an exclusive lock on an "owner" (a model or a parent element), implicitly exclusively locks all its members. */ LockState[LockState["Exclusive"] = 2] = "Exclusive"; })(LockState || (exports.LockState = LockState = {})); /** * An error raised when there is a lock conflict detected. * Typically this error would be thrown by [LockControl.acquireLocks]($backend) when you are requesting a lock on an element that is already held by another briefcase. * @public */ class ConflictingLocksError extends IModelError { conflictingLocks; /** @beta */ static isError(error) { return core_bentley_1.BentleyError.isError(error, core_bentley_1.IModelHubStatus.LockOwnedByAnotherBriefcase); } constructor(message, getMetaData, conflictingLocks) { super(core_bentley_1.IModelHubStatus.LockOwnedByAnotherBriefcase, message, getMetaData); this.conflictingLocks = conflictingLocks; } } exports.ConflictingLocksError = ConflictingLocksError; /** @public */ class ServerError extends IModelError { constructor(errorNumber, message) { super(errorNumber, message); this.name = `Server error (${errorNumber})`; } } exports.ServerError = ServerError; /** @public */ class ServerTimeoutError extends ServerError { constructor(message) { super(core_bentley_1.IModelStatus.ServerTimeout, message); this.name = "Server timeout error"; } } exports.ServerTimeoutError = ServerTimeoutError; /** @public */ class BackendError extends IModelError { constructor(errorNumber, name, message, getMetaData) { super(errorNumber, message, getMetaData); this.name = name; } } exports.BackendError = BackendError; /** Intended for API "no content" semantics where the error case should not trigger application failure monitoring systems. * @public */ class NoContentError extends IModelError { constructor() { super(core_bentley_1.IModelStatus.NoContent, "No Content"); } } exports.NoContentError = NoContentError; //# sourceMappingURL=IModelError.js.map