result
result ¶
Simple result type for error handling.
This module provides a basic Result type pattern for handling success and failure cases in a more explicit way than exceptions. It helps distinguish between empty data and error conditions, making the code more maintainable and debuggable.
Example usage
from journal_lib.result import Result, Success, Failure
def some_operation() -> Result[str]: if success_condition: return Success("operation result") else: return Failure("error message")
result = some_operation() if result.is_success(): print(f"Got: {result.value}") else: print(f"Error: {result.error}")