error_message_from_response

Function error_message_from_response 

Source
pub async fn error_message_from_response(
    response: Response,
    default_message: &str,
) -> String
Expand description

Extract the most meaningful error message from an HTTP response. This is useful for handling OAuth2 / OpenID Connect Bearer errors

Extraction order:

  1. If the WWW-Authenticate header exists and contains a Bearer error:
    • Return error_description if present
    • Else return error if present
    • Else join all string values in the header
  2. If no usable info is found in the header:
    • Return the response body text
    • If body cannot be read, return default_message