'use strict';

var chunk64ITUOXI_cjs = require('./chunk-64ITUOXI.cjs');

// 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 chunk64ITUOXI_cjs.HTTPException(apiErrorStatus, {
    message: apiError.message || defaultMessage,
    stack: apiError.stack,
    cause: apiError.cause
  });
}

exports.formatZodError = formatZodError;
exports.handleError = handleError;
//# sourceMappingURL=chunk-Y2BKW5ND.cjs.map
//# sourceMappingURL=chunk-Y2BKW5ND.cjs.map