name: error-handling description: | Use when throwing, catching, wrapping, documenting, or testing runtime errors in aa-sdk packages. last_verified: 2026-05-06
Error Handling
Runtime package errors should use the SDK error hierarchy rooted at
@alchemy/common BaseError.
Rules
| Rule | When to read |
|---|---|
| BaseError | Before adding package runtime errors. |
| No plain Error | Before writing throw statements in packages/. |
| Raise footgun | Before using or modifying raise. |
Evidence
packages/common/src/errors/BaseError.tsextends viem'sBaseError..eslintrcforbidsthrow new Error(...)inpackages/**/*except tests..eslintrcforbidsimport { BaseError } from "viem"to prevent accidentally using viem'sBaseErrorinstead of@alchemy/common's.packages/wallet-apis/src/utils/schema.tswraps Zod validation failures in@alchemy/commonBaseError.