import { HTTPException } from './chunk-6QWQZI4Q.js';

// src/server/handlers/error.ts
function formatZodError(error, context) {
  const issues = error.issues.map((e) => ({
    field: e.path.length > 0 ? e.path.map((p) => String(p)).join(".") : "root",
    message: e.message
  }));
  return {
    error: `Invalid ${context}`,
    issues
  };
}
function handleError(error, defaultMessage) {
  const apiError = error;
  const apiErrorStatus = apiError.status || apiError.details?.status || 500;
  throw new HTTPException(apiErrorStatus, {
    message: apiError.message || defaultMessage,
    stack: apiError.stack,
    cause: apiError.cause
  });
}

export { formatZodError, handleError };
//# sourceMappingURL=chunk-NA7LKQPZ.js.map
//# sourceMappingURL=chunk-NA7LKQPZ.js.map