create_error_response

Function create_error_response 

Source
pub fn create_error_response(
    status: StatusCode,
    message: &str,
) -> Response<Full<Bytes>>
Expand description

Creates a standardized error response.

Builds an HTTP response with the given status code and plain text message. Falls back to a minimal 500 response if building fails (should never happen with valid StatusCode).

§Arguments

  • status - The HTTP status code for the response
  • message - The plain text error message body

§Returns

An HTTP response with content-type: text/plain header.

§Example

use wisegate_core::request_handler::create_error_response;
use hyper::StatusCode;

let response = create_error_response(StatusCode::NOT_FOUND, "Resource not found");
assert_eq!(response.status(), StatusCode::NOT_FOUND);