Merge pull request 'fix: getErrorMessage silently ignores viem's shortMessage (#430)' (#484) from fix/issue-430 into master

This commit is contained in:
johba 2026-03-06 06:41:25 +01:00
commit 67c0ed953a

View file

@ -14,6 +14,9 @@ export function coerceString(value: unknown): string | null {
export function getErrorMessage(error: unknown, fallback: string): string {
if (error instanceof Error) {
// viem's BaseError extends Error and exposes a terse shortMessage; prefer it.
const short = coerceString((error as unknown as Record<string, unknown>).shortMessage);
if (short) return short;
const msg = coerceString(error.message);
if (msg) return msg;
}