# std-error-handling > Error handling best practices for user-friendly messages, fail-fast patterns, and graceful degradation - Author: Lilu Douglas - Repository: devalexanderdaza/opencode-workflow - Version: 20260114232758 - Stars: 0 - Forks: 0 - Last Updated: 2026-02-06 - Source: https://github.com/devalexanderdaza/opencode-workflow - Web: https://mule.run/skillshub/@@devalexanderdaza/opencode-workflow~std-error-handling:20260114232758 --- --- name: std-error-handling description: Error handling best practices for user-friendly messages, fail-fast patterns, and graceful degradation --- ## Error handling best practices - **User-Friendly Messages**: Provide clear, actionable error messages to users without exposing technical details or security information - **Fail Fast and Explicitly**: Validate input and check preconditions early; fail with clear error messages rather than allowing invalid state - **Specific Exception Types**: Use specific exception/error types rather than generic ones to enable targeted handling - **Centralized Error Handling**: Handle errors at appropriate boundaries (controllers, API layers) rather than scattering try-catch blocks everywhere - **Graceful Degradation**: Design systems to degrade gracefully when non-critical services fail rather than breaking entirely - **Retry Strategies**: Implement exponential backoff for transient failures in external service calls - **Clean Up Resources**: Always clean up resources (file handles, connections) in finally blocks or equivalent mechanisms