@talak-web3/errors
v1.0.11
Published
Standardized error handling for talak-web3.
Readme
@talak-web3/errors
Standardized error handling for talak-web3.
Installation
npm install @talak-web3/errors
# or
yarn add @talak-web3/errors
# or
pnpm add @talak-web3/errorsUsage
import {
TalakError,
AuthError,
RpcError,
ValidationError
} from '@talak-web3/errors';
// Throw standardized errors
throw new AuthError('Invalid signature', {
code: 'AUTH_INVALID_SIGNATURE',
statusCode: 401,
});
// Handle errors
try {
await authenticate(message, signature);
} catch (error) {
if (error instanceof AuthError) {
console.log(error.code); // 'AUTH_INVALID_SIGNATURE'
console.log(error.statusCode); // 401
}
}Error Types
TalakError- Base error classAuthError- Authentication errorsRpcError- RPC/Blockchain errorsValidationError- Input validation errorsConfigError- Configuration errorsNetworkError- Network-related errors
License
MIT
