import { t as Json } from "./json-a1QIXu5z.js"; //#region src/utils/errors.d.ts declare function throwErr(errorMessage: string, extraData?: any): never; declare function throwErr(error: Error): never; declare function throwErr(...args: StatusErrorConstructorParameters): never; /** * Concatenates the (original) stacktraces of the given errors onto the first. * * Note: Very often, the concatStacktracesIfRejected function in promises.tsx is an easier way to use this function. * * Useful when you invoke an async function to receive a promise without awaiting it immediately. Browsers are smart * enough to keep track of the call stack in async function calls when you invoke `.then` within the same async tick, * but if you don't, the stacktrace will be lost. * * Here's an example of the unwanted behavior: * * ```tsx * async function log() { * await wait(0); // put the task on the event loop * console.log(new Error().stack); * } * * async function main() { * await log(); // good; prints both "log" and "main" on the stacktrace * log(); // bad; prints only "log" on the stacktrace * } * ``` */ declare function concatStacktraces(first: Error, ...errors: Error[]): void; declare class HexclaveAssertionError extends Error { readonly extraData?: (Record & ErrorOptions) | undefined; constructor(message: string, extraData?: (Record & ErrorOptions) | undefined); } /** * An error caused by an incomplete or incorrect Hexclave setup in the developer's own project — a domain that has not * been added to the project's trusted domains, for example. * * These are neither the end user's fault nor a bug in Hexclave, and they are usually fatal for the flow they occur in (an * auth handoff that can never complete, say). Only logging them would leave the developer with a broken flow and no * visible explanation, so the SDK also renders them on the page; `title` and `howToFix` end up in that card, so write * them as instructions to the developer rather than as internal diagnostics. */ declare class HexclaveSetupError extends Error { readonly title: string; readonly howToFix: readonly string[]; constructor(options: { title: string; message: string; howToFix: readonly string[]; extraData?: Record & ErrorOptions; }); /** * Like `instanceof`, but also true for setup errors thrown by another copy of this package — an app can easily end up * with two of them, and a setup error from either must still show up as one. */ static isSetupError(error: unknown): error is HexclaveSetupError; } declare function errorToNiceString(error: unknown): string; type CaptureLevel = "error" | "warning"; type ErrorSink = (location: string, error: unknown, level: CaptureLevel, ...extraArgs: unknown[]) => void; declare function registerErrorSink(sink: ErrorSink): void; /** * Captures an error and sends it to the error sinks (most notably, Sentry). Errors caught with captureError are * supposed to be seen by an engineer, so they should be actionable and important. * * The location string is a machine-readable ID, and should hence not contain spaces or anything like that. Good * examples are: "api-route-handler", "renderPart()", etc. * * Errors that bubble up to the top of runAsynchronously or a route handler are already captured with captureError. */ declare function captureError(location: string, error: unknown): void; /** * Like captureError, but logs at warning level. Use for issues that an engineer should know about but that aren't * severe enough to be treated as an error (e.g. recoverable failures in background tasks). */ declare function captureWarning(location: string, error: unknown): void; type Status = { statusCode: number; message: string; }; type StatusErrorConstructorParameters = [status: Status, message?: string] | [statusCode: number | Status, message: string]; declare class StatusError extends Error { private readonly __stackStatusErrorBrand; name: string; readonly statusCode: number; static BadRequest: { statusCode: number; message: string; }; static Unauthorized: { statusCode: number; message: string; }; static PaymentRequired: { statusCode: number; message: string; }; static Forbidden: { statusCode: number; message: string; }; static NotFound: { statusCode: number; message: string; }; static MethodNotAllowed: { statusCode: number; message: string; }; static NotAcceptable: { statusCode: number; message: string; }; static ProxyAuthenticationRequired: { statusCode: number; message: string; }; static RequestTimeout: { statusCode: number; message: string; }; static Conflict: { statusCode: number; message: string; }; static Gone: { statusCode: number; message: string; }; static LengthRequired: { statusCode: number; message: string; }; static PreconditionFailed: { statusCode: number; message: string; }; static PayloadTooLarge: { statusCode: number; message: string; }; static URITooLong: { statusCode: number; message: string; }; static UnsupportedMediaType: { statusCode: number; message: string; }; static RangeNotSatisfiable: { statusCode: number; message: string; }; static ExpectationFailed: { statusCode: number; message: string; }; static ImATeapot: { statusCode: number; message: string; }; static MisdirectedRequest: { statusCode: number; message: string; }; static UnprocessableEntity: { statusCode: number; message: string; }; static Locked: { statusCode: number; message: string; }; static FailedDependency: { statusCode: number; message: string; }; static TooEarly: { statusCode: number; message: string; }; static UpgradeRequired: { statusCode: number; message: string; }; static PreconditionRequired: { statusCode: number; message: string; }; static TooManyRequests: { statusCode: number; message: string; }; static RequestHeaderFieldsTooLarge: { statusCode: number; message: string; }; static UnavailableForLegalReasons: { statusCode: number; message: string; }; static InternalServerError: { statusCode: number; message: string; }; static NotImplemented: { statusCode: number; message: string; }; static BadGateway: { statusCode: number; message: string; }; static ServiceUnavailable: { statusCode: number; message: string; }; static GatewayTimeout: { statusCode: number; message: string; }; static HTTPVersionNotSupported: { statusCode: number; message: string; }; static VariantAlsoNegotiates: { statusCode: number; message: string; }; static InsufficientStorage: { statusCode: number; message: string; }; static LoopDetected: { statusCode: number; message: string; }; static NotExtended: { statusCode: number; message: string; }; static NetworkAuthenticationRequired: { statusCode: number; message: string; }; constructor(...args: StatusErrorConstructorParameters); static isStatusError(error: unknown): error is StatusError; isClientError(): boolean; isServerError(): boolean; getStatusCode(): number; getBody(): Uint8Array; getHeaders(): Record; toDescriptiveJson(): Json; /** * @deprecated this is not a good way to make status errors human-readable, use toDescriptiveJson instead */ toHttpJson(): Json; } //#endregion export { captureError as a, errorToNiceString as c, StatusError as i, registerErrorSink as l, HexclaveAssertionError as n, captureWarning as o, HexclaveSetupError as r, concatStacktraces as s, CaptureLevel as t, throwErr as u }; //# sourceMappingURL=errors-BpRwtQ-E.d.ts.map