UNPKG

@beignet/core

Version:

Core framework primitives for Beignet

23 lines 831 B
import { isContractError } from "./client.js"; /** * Map an unknown error to user-facing copy. * * Non-`ContractError` values return the fallback. Override copy per catalog * code with `overrides`. Client-side input validation failures return a * generic "check the highlighted fields" message; other contract errors * return the error message. */ export function contractErrorMessage(error, fallback, overrides = {}) { if (!isContractError(error)) { return fallback; } const override = error.code ? overrides[error.code] : undefined; if (override) { return override; } if (error.hasSource("client") && error.hasCode("INPUT_VALIDATION_ERROR")) { return "Check the highlighted fields and try again."; } return error.message; } //# sourceMappingURL=error-messages.js.map