Skip to main content

Module error

Module error 

Source
Expand description

§Open Payments Client Error Types

This module defines the error types used throughout the Open Payments client. All client operations return a Result<T, OpClientError> which provides detailed error information for different failure scenarios.

§Error Structure

  • description - Human-readable error message
  • validationErrors - Optional list of validation error messages
  • status - HTTP status code (only for HTTP errors)
  • code - Error code (only for HTTP errors)
  • details - Additional error details as key-value pairs

§Example Usage

use open_payments::client::{OpClientError, Result};

fn handle_client_error(result: Result<()>) {
    match result {
        Ok(()) => println!("Operation successful"),
        Err(e) => {
            eprintln!("Error: {}", e.description);
            if let Some(status) = e.status {
                eprintln!("Status: {}", status);
            }
            if let Some(code) = e.code {
                eprintln!("Code: {}", code);
            }
            if let Some(validation_errors) = e.validation_errors {
                for error in validation_errors {
                    eprintln!("Validation error: {}", error);
                }
            }
        }
    }
}

Structs§

OpClientError
Error type for Open Payments client operations.

Type Aliases§

Result
Result type for Open Payments client operations.