Merge pull request 'fix: getErrorMessage silently ignores viem's shortMessage (#430)' (#484) from fix/issue-430 into master
This commit is contained in:
commit
67c0ed953a
1 changed files with 3 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue