import { z } from "zod";

export const ErrorResponse = z.object({
	error: z.object({
		message: z.string(),
		context: z.record(z.string(), z.unknown()).or(z.null()),
	}),
});
export type ErrorResponse = z.infer<typeof ErrorResponse>;

export function createErrorResponse(context = z.object().optional()) {
	return z.object({
		error: z.object({
			message: z.string(),
			context,
		}),
	});
}
