Skip to main content

Module error

Module error 

Source
Expand description

Error Handling Module - Presentation Layer

This module provides error handling functionality for the presentation layer, specifically focusing on displaying errors to users in a helpful and actionable way.

§Purpose

The error handling module is responsible for:

  • User-Friendly Error Display: Converting internal errors to readable messages
  • Actionable Guidance: Providing specific steps users can take to resolve issues
  • Fallback Handling: Ensuring error messages are displayed even in degraded states
  • Consistent Formatting: Maintaining consistent error output across all commands

§Design Principles

  • Observability: All errors include sufficient context for debugging
  • Actionability: Error messages tell users how to fix problems
  • Reliability: Error handling itself must not fail
  • Consistency: All errors follow the same display patterns

§Module Integration

This module integrates with:

  • CommandError Types - Uses structured error types from presentation::cli::errors
  • UserOutput Service - Leverages user output for consistent formatting
  • Help System - Displays detailed troubleshooting via .help() method

§Usage

use std::sync::Arc;
use std::cell::RefCell;
use parking_lot::ReentrantMutex;
use torrust_tracker_deployer_lib::presentation::cli::error;
use torrust_tracker_deployer_lib::presentation::cli::errors::CommandError;
use torrust_tracker_deployer_lib::presentation::cli::views;

// Display error with detailed troubleshooting
error::handle_error(&error, &user_output);

Functions§

handle_error
Handle command errors with consistent user output