inngest
Version:
Official SDK for Inngest.com. Inngest is the reliability layer for modern applications. Inngest combines durable execution, events, and queues into a zero-infra platform with built-in observability.
110 lines (109 loc) • 4.49 kB
TypeScript
import { OutgoingOp } from "../types.js";
import { SerializedError } from "serialize-error-cjs";
//#region src/helpers/errors.d.ts
declare namespace errors_d_exports {
export { ErrCode, OutgoingResultError, SerializedError$1 as SerializedError, deserializeError$1 as deserializeError, fixEventKeyMissingSteps, getErrorMessage, isSerializedError, rethrowError, serializeError$1 as serializeError };
}
declare const SERIALIZED_KEY = "__serialized";
declare const SERIALIZED_VALUE = true;
interface SerializedError$1 extends Readonly<SerializedError> {
readonly [SERIALIZED_KEY]: typeof SERIALIZED_VALUE;
}
/**
* Serialise an error to a serialized JSON string.
*
* Errors do not serialise nicely to JSON, so we use this function to convert
* them to a serialized JSON string. Doing this is also non-trivial for some
* errors, so we use the `serialize-error` package to do it for us.
*
* See {@link https://www.npmjs.com/package/serialize-error}
*
* This function is a small wrapper around that package to also add a `type`
* property to the serialised error, so that we can distinguish between
* serialised errors and other objects.
*
* Will not reserialise existing serialised errors.
*/
declare const serializeError$1: <TAllowUnknown extends boolean = false, TOutput extends (TAllowUnknown extends true ? unknown : SerializedError$1) = (TAllowUnknown extends true ? unknown : SerializedError$1)>(
/**
* The suspected error to serialize.
*/
subject: unknown,
/**
* If `true` and the error is not serializable, will return the original value
* as `unknown` instead of coercing it to a serialized error.
*/
allowUnknown?: TAllowUnknown) => TOutput;
/**
* Check if an object or a string is a serialised error created by
* {@link serializeError}.
*/
declare const isSerializedError: (value: unknown) => SerializedError$1 | undefined;
/**
* Deserialise an error created by {@link serializeError}.
*
* Ensures we only deserialise errors that meet a minimum level of
* applicability, inclusive of error handling to ensure that badly serialized
* errors are still handled.
*/
declare const deserializeError$1: <TAllowUnknown extends boolean = false, TOutput extends (TAllowUnknown extends true ? unknown : Error) = (TAllowUnknown extends true ? unknown : Error)>(subject: Partial<SerializedError$1>, allowUnknown?: TAllowUnknown) => TOutput;
declare enum ErrCode {
NESTING_STEPS = "NESTING_STEPS",
/**
* Legacy v0 execution error code for when a function has changed and no
* longer matches its in-progress state.
*
* @deprecated Not for use in latest execution method.
*/
NON_DETERMINISTIC_FUNCTION = "NON_DETERMINISTIC_FUNCTION",
/**
* Legacy v0 execution error code for when a function is found to be using
* async actions after memoziation has occurred, which v0 doesn't support.
*
* @deprecated Not for use in latest execution method.
*/
ASYNC_DETECTED_AFTER_MEMOIZATION = "ASYNC_DETECTED_AFTER_MEMOIZATION",
/**
* Legacy v0 execution error code for when a function is found to be using
* steps after a non-step async action has occurred.
*
* @deprecated Not for use in latest execution method.
*/
STEP_USED_AFTER_ASYNC = "STEP_USED_AFTER_ASYNC",
AUTOMATIC_PARALLEL_INDEXING = "AUTOMATIC_PARALLEL_INDEXING",
NONDETERMINISTIC_STEPS = "NONDETERMINISTIC_STEPS",
}
/**
* Given an `unknown` object, retrieve the `message` property from it, or fall
* back to the `fallback` string if it doesn't exist or is empty.
*/
declare const getErrorMessage: (err: unknown, fallback: string) => string;
declare const fixEventKeyMissingSteps: string[];
/**
* An error that, when thrown, indicates internally that an outgoing operation
* contains an error.
*
* We use this because serialized `data` sent back to Inngest may differ from
* the error instance itself due to middleware.
*
* @internal
*/
declare class OutgoingResultError extends Error {
readonly result: Pick<OutgoingOp, "data" | "error">;
constructor(result: Pick<OutgoingOp, "data" | "error">);
}
/**
* Create a function that will rethrow an error with a prefix added to the
* message.
*
* Useful for adding context to errors that are rethrown.
*
* @example
* ```ts
* await doSomeAction().catch(rethrowError("Failed to do some action"));
* ```
*/
declare const rethrowError: (prefix: string) => ((err: any) => never);
//#endregion
export { errors_d_exports, serializeError$1 as serializeError };
//# sourceMappingURL=errors.d.ts.map