Why Exceptions?
Voltaire primitives stay close to TypeScript and Ethereum specifications. Since JavaScript’s native APIs throw exceptions (e.g.,JSON.parse, new URL), Voltaire follows the same pattern for consistency.
However, we recommend wrapping Voltaire in more error-safe patterns for application code:
- neverthrow — Lightweight Result type for TypeScript
- Effect.ts — Full-featured typed effects system (Voltaire provides
/effectexports)
Basic Pattern
Constructors throw when given invalid input:Error Hierarchy
All errors extendPrimitiveError:
Error Metadata
Every error includes debugging information:| Field | Type | Description |
|---|---|---|
name | string | Error class name |
code | string | Machine-readable code |
value | unknown | The invalid input |
expected | string | What was expected |
docsPath | string | Link to documentation |
context | object | Additional debug info |
cause | Error | Original error (if wrapped) |
Validation Functions
Three ways to validate:- Constructor: When invalid input is unexpected
- isValid: When you want to branch on validity
- assert: When you need validation options (like
strictchecksum)
Checking Error Types
Useinstanceof to check error types:
code field for simpler handling:
Effect.ts Integration
For advanced use cases, Voltaire provides Effect.ts schemas:Data.TaggedError:
@tevm/voltaire/effect subpath. Regular usage just throws standard exceptions.

