@kellanjs/actioncraft
Version:
Fluent, type-safe builder for Next.js server actions.
22 lines • 840 B
JavaScript
/**
* Error wrapper that provides standard Error semantics while preserving
* the original ActionCraft error data in the cause property.
*/
export class ActionCraftError extends Error {
cause;
constructor(errorData) {
super(`ActionCraft Error: ${errorData.type}${"message" in errorData ? ` - ${errorData.message}` : ""}`);
this.name = "ActionCraftError";
this.cause = errorData;
// Ensure proper prototype chain for instanceof checks
Object.setPrototypeOf(this, ActionCraftError.prototype);
}
}
/**
* Type guard to check if an error is an ActionCraftError with the action's error types.
* The action parameter is used purely for type inference.
*/
export function isActionCraftError(error, _action) {
return error instanceof ActionCraftError;
}
//# sourceMappingURL=error.js.map