import { getErrorMessage, getErrorDetails } from "../../shared/src/error.js";
class ApplicationError extends Error {
  /**
   * This maps onto errors for transform and push app-level failures.
   */
  #details;
  constructor(message, options) {
    super(message, { cause: options?.cause });
    this.name = "ApplicationError";
    this.#details = options?.details ?? void 0;
  }
  get details() {
    return this.#details;
  }
  get kind() {
    return "Application";
  }
}
function isApplicationError(error) {
  return error instanceof ApplicationError;
}
function wrapWithApplicationError(error) {
  if (isApplicationError(error)) {
    return error;
  }
  const message = getErrorMessage(error);
  const details = getErrorDetails(error);
  return new ApplicationError(message, {
    cause: error,
    details
  });
}
export {
  ApplicationError,
  isApplicationError,
  wrapWithApplicationError
};
//# sourceMappingURL=application-error.js.map
