var _a, _b;
const COMMAND_INTERCEPTOR_ERROR_MARKER = /* @__PURE__ */ Symbol.for("@open-mercato/CommandInterceptorError");
class CommandInterceptorError extends (_b = Error, _a = COMMAND_INTERCEPTOR_ERROR_MARKER, _b) {
  constructor(message, options) {
    super(message, options?.cause !== void 0 ? { cause: options.cause } : void 0);
    this[_a] = true;
    this.name = "CommandInterceptorError";
    if (typeof options?.status === "number") {
      this.status = options.status;
      this.body = options.body ?? { error: message };
    }
  }
}
function isCommandInterceptorError(err) {
  return !!err && typeof err === "object" && err[COMMAND_INTERCEPTOR_ERROR_MARKER] === true;
}
const MIN_REJECTION_STATUS = 400;
const MAX_REJECTION_STATUS = 599;
function getCommandInterceptorHttpRejection(err) {
  if (!isCommandInterceptorError(err)) return null;
  const status = err.status;
  if (typeof status !== "number" || !Number.isInteger(status)) return null;
  if (status < MIN_REJECTION_STATUS || status > MAX_REJECTION_STATUS) return null;
  return { status, body: err.body ?? { error: err.message } };
}
export {
  CommandInterceptorError,
  getCommandInterceptorHttpRejection,
  isCommandInterceptorError
};
//# sourceMappingURL=errors.js.map
