/** @packageDocumentation
 * @module iModels
 */
import { LoggingMetaData } from "@itwin/core-bentley";
import { LockState } from "./IModelError";
/**
 * Detailed information about a particular object Lock that is causing the Lock update conflict.
 * An example of a lock update conflict would be attempting to use [LockControl.acquireLocks]($backend) on an object that is already locked by another Briefcase.
 * @beta
 */
export interface InUseLock {
    /** Id of the object that is causing conflict. */
    objectId: string;
    /**
     * The level of conflicting lock. Possible values are {@link LockState.Shared}, {@link LockState.Exclusive}.
     * See {@link LockState}.
     */
    state: LockState;
    /** An array of Briefcase ids that hold this lock. */
    briefcaseIds: number[];
}
/**
 * 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 [[InUseLocksError.throwInUseLocksError]] and [[InUseLocksError.isInUseLocksError]] for examples of how to throw and check that an error is of type InUseLocksError.
 * * Example of catching a ITwinError:
 * ``` ts
 * [[include:ITwinError.catchAndHandleITwinError]]
 * ```
 * @beta
 */
export interface ITwinError {
    /** namespace for the error. This is a unique qualifier for the errorKey. */
    namespace: string;
    /** unique key for error, within namespace. All errorKeys within the same namespace must be unique. */
    errorKey: string;
    /** explanation of what went wrong. Intended to be read by a developer. */
    message: string;
    /** stack trace of the error. */
    stack?: string;
    /** metadata about the exception. */
    metadata?: LoggingMetaData;
}
/**
 * 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.
 * @beta
*/
export interface InUseLocksError extends ITwinError {
    namespace: "itwinjs-core";
    errorKey: "in-use-locks";
    inUseLocks: InUseLock[];
}
/** @beta */
export declare namespace InUseLocksError {
    /**
     * type guard function that returns whether or not the passed in parameter is an [[InUseLocksError]].
     * it first checks [[ITwinError.isITwinError]] and then checks that the namespace property is "itwinjs-core" and the errorKey property is "in-use-locks".
     */
    function isInUseLocksError(error: unknown): error is InUseLocksError;
    /** throws an error which passes the [[InUseLocksError.isInUseLocksError]] type guard function */
    function throwInUseLocksError(inUseLocks: InUseLock[], message?: string, metadata?: LoggingMetaData): never;
}
/** @beta */
export declare namespace ITwinError {
    /** type guard function that returns whether or not the passed in parameter is an [[ITwinError]] */
    function isITwinError(error: unknown): error is ITwinError;
    /** get the meta data associated with this ITwinError, if any. */
    function getMetaData(err: ITwinError): object | undefined;
}
//# sourceMappingURL=ITwinError.d.ts.map