create_custom_error

Function create_custom_error 

Source
pub fn create_custom_error(
    status: StatusCode,
    message: impl Into<String>,
    error_type: Option<String>,
    include_details: bool,
) -> ErrorResponse
Expand description

Creates a custom error response with a specific message and status code.

This function allows you to create custom error responses for specific error conditions in your application.

§Arguments

  • status - HTTP status code
  • message - Error message
  • error_type - Optional error type identifier
  • include_details - Whether to include detailed error information

§Returns

An ErrorResponse with the specified status code and message.

§Example

use streamweave::http_server::error::create_custom_error;
use axum::http::StatusCode;

let error = create_custom_error(
    StatusCode::BAD_REQUEST,
    "Invalid user ID format",
    Some("InvalidUserIdError".to_string()),
    false,
);