@itwin/core-common
Version:
iTwin.js components common to frontend and backend
78 lines • 3.17 kB
JavaScript
/*---------------------------------------------------------------------------------------------
* 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
*/
import { BentleyError, IModelHubStatus, IModelStatus, } from "@itwin/core-bentley";
/** The error type thrown by this module.
* @see [[ITwinError]]
* @see [[IModelErrorNumber]] for commonly-used error codes.
* @public
*/
export class IModelError extends BentleyError {
constructor(errorNumber, message, getMetaData) {
super(errorNumber, message, getMetaData);
}
}
/** The state of a lock. See [Acquiring locks on elements.]($docs/learning/backend/ConcurrencyControl.md#acquiring-locks-on-elements).
* @public
*/
export 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 || (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
*/
export class ConflictingLocksError extends IModelError {
conflictingLocks;
/** @beta */
static isError(error) {
return BentleyError.isError(error, IModelHubStatus.LockOwnedByAnotherBriefcase);
}
constructor(message, getMetaData, conflictingLocks) {
super(IModelHubStatus.LockOwnedByAnotherBriefcase, message, getMetaData);
this.conflictingLocks = conflictingLocks;
}
}
/** @public */
export class ServerError extends IModelError {
constructor(errorNumber, message) {
super(errorNumber, message);
this.name = `Server error (${errorNumber})`;
}
}
/** @public */
export class ServerTimeoutError extends ServerError {
constructor(message) {
super(IModelStatus.ServerTimeout, message);
this.name = "Server timeout error";
}
}
/** @public */
export class BackendError extends IModelError {
constructor(errorNumber, name, message, getMetaData) {
super(errorNumber, message, getMetaData);
this.name = name;
}
}
/** Intended for API "no content" semantics where the error case should not trigger application failure monitoring systems.
* @public
*/
export class NoContentError extends IModelError {
constructor() {
super(IModelStatus.NoContent, "No Content");
}
}
//# sourceMappingURL=IModelError.js.map