Skip to main content

Module errors

Module errors 

Source
Expand description

Error types for the Deboa HTTP client.

This module contains the error types used throughout the Deboa HTTP client. The main error type is DeboaError, which can represent various kinds of errors that might occur during HTTP requests and responses.

§Error Types

  • DeboaError: The main error type that can represent any error that occurs in Deboa
  • RequestError: Errors that occur while building or sending HTTP requests
  • ResponseError: Errors that occur while processing HTTP responses
  • ConnectionError: Errors that occur during network connections
  • ContentError: Errors related to content serialization/deserialization
  • IoError: I/O related errors

§Examples

§Handling Errors

use deboa::{Deboa, request::get};
use deboa::errors::DeboaError;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
  let mut client = Deboa::default();

  match get("https://example.com").and_then(|req| req.send_with(&mut client)) {
    Ok(response) => {
        // Handle successful response
    },
    Err(DeboaError::Connection(e)) => {
        // Handle connection errors
        eprintln!("Connection failed: {}", e);
    },
    Err(DeboaError::Request(e)) => {
        // Handle request errors
        eprintln!("Request failed: {}", e);
    },
    Err(e) => {
        // Handle other errors
        eprintln!("Error: {}", e);
    }
  }
  Ok(())
}

Enums§

ConnectionError
ContentError
DeboaError
The main error type for the Deboa HTTP client.
IoError
RequestError
ResponseError