-
Notifications
You must be signed in to change notification settings - Fork 0
Error
prasad-kumkar edited this page May 5, 2025
·
1 revision
The jam.error module provides a standardized approach to error handling throughout the Tessera implementation.
Tessera defines a hierarchy of error types to handle different categories of errors:
-
JamError - Base exception class for all Tessera errors
- ConfigError - Configuration-related errors
- NetworkError - Network communication errors
- ConsensusError - Errors in consensus mechanisms
- ValidationError - Block or transaction validation errors
- StateError - State management errors
- StorageError - Database and storage errors
- CryptoError - Cryptography-related errors
from jam.error import JamError, ValidationError
def validate_block(block):
try:
# Validation logic
if not is_valid_format(block):
raise ValidationError("Invalid block format")
if not valid_signature(block):
raise ValidationError("Invalid block signature")
except ValidationError as e:
# Handle validation errors
logger.error(f"Block validation failed: {e}")
return False
except JamError as e:
# Handle other Tessera errors
logger.error(f"Unexpected error during validation: {e}")
return False
except Exception as e:
# Handle unexpected errors
logger.error(f"System error: {e}")
return False
return TrueWhen working with errors in Tessera:
- Specific Exceptions: Use the most specific error type for the situation
- Error Context: Include relevant context in error messages
- Error Propagation: Handle errors at the appropriate level
- Error Logging: Log errors with appropriate severity
- Custom Errors: Extend the base classes when creating custom errors