/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ import type { ITelemetryBaseProperties } from "@fluidframework/core-interfaces"; import { type ILayerIncompatibilityError } from "@fluidframework/core-interfaces/internal"; import type { ITelemetryPropertiesExt } from "./telemetryTypes.js"; /** * An error emitted by the Fluid Framework. * * @remarks * * All normalized errors flowing through the Fluid Framework adhere to this readonly interface. * * It features the members of {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error | Error} * made readonly, as well as {@link IFluidErrorBase.errorType} and {@link IFluidErrorBase.errorInstanceId}. * It also features getters and setters for telemetry props to be included when the error is logged. * * @internal */ export interface IFluidErrorBase extends Error { /** * Classification of what type of error this is. * * @remarks Used programmatically by consumers to interpret the error. */ readonly errorType: string; /** * Error's message property, made readonly. * * @remarks * * Recommendations: * * Be specific, but also take care when including variable data to consider suitability for aggregation in telemetry. * Also avoid including any data that jeopardizes the user's privacy. Add a tagged telemetry property instead. */ readonly message: string; /** * See {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack}. */ readonly stack?: string; /** * See {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name}. */ readonly name: string; /** * A Guid identifying this error instance. * * @remarks * * Useful in telemetry for deduplicating multiple logging events arising from the same error, * or correlating an error with an inner error that caused it, in case of error wrapping. */ readonly errorInstanceId: string; /** * When present, inner error that caused this error. * * @remarks * This will often be an {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error|Error}, but could be any type. * * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause * * @privateRemarks * The "cause" field is added in ES2022. Using it even without that built-in support, is still helpful. * TODO: remove this declaration (use `Error.cause` property) when targeting ES2022 lib or later. */ cause?: unknown; /** * Get the telemetry properties stashed on this error for logging. */ getTelemetryProperties(): ITelemetryBaseProperties; /** * Add telemetry properties to this error which will be logged with the error */ addTelemetryProperties: (props: ITelemetryPropertiesExt) => void; } /** * Type guard for error data containing the {@link IFluidErrorBase.errorInstanceId} property. * * @internal */ export declare const hasErrorInstanceId: (x: unknown) => x is { errorInstanceId: string; }; /** * Type guard for {@link IFluidErrorBase}. * * @internal */ export declare function isFluidError(error: unknown): error is IFluidErrorBase; /** * Helper that returns whether the provided error is a layer incompatibility error. * * @internal */ export declare function isLayerIncompatibilityError(error: unknown): error is ILayerIncompatibilityError; //# sourceMappingURL=fluidErrorBase.d.ts.map