userver: server::http::CustomHandlerException Class Reference
Loading...
Searching...
No Matches
server::http::CustomHandlerException Class Reference

#include <userver/server/http/http_error.hpp>

Detailed Description

An extension of server::handlers::CustomHandlerException that allows to specify a custom HttpStatus.

For non-HTTP protocols, the status code will be derived from the attached server::handlers::HandlerErrorCode.

Definition at line 37 of file http_error.hpp.

+ Inheritance diagram for server::http::CustomHandlerException:

Public Types

using HandlerErrorCode = handlers::HandlerErrorCode
 
using ServiceErrorCode = handlers::ServiceErrorCode
 
using InternalMessage = handlers::InternalMessage
 
using ExternalBody = handlers::ExternalBody
 
using ExtraHeaders = handlers::ExtraHeaders
 

Public Member Functions

template<typename... Args>
 CustomHandlerException (handlers::HandlerErrorCode error_code, HttpStatus http_status, Args &&... args)
 
HttpStatus GetHttpStatus () const
 
HandlerErrorCode GetCode () const
 
const std::string & GetServiceCode () const
 
bool IsExternalErrorBodyFormatted () const
 
const std::string & GetExternalErrorBody () const
 
const formats::json::ValueGetDetails () const
 
const Headers & GetExtraHeaders () const
 

Member Typedef Documentation

◆ ExternalBody

◆ ExtraHeaders

◆ HandlerErrorCode

◆ InternalMessage

◆ ServiceErrorCode

Constructor & Destructor Documentation

◆ CustomHandlerException()

template<typename... Args>
server::http::CustomHandlerException::CustomHandlerException ( handlers::HandlerErrorCode error_code,
HttpStatus http_status,
Args &&... args )
inline
See also
server::handlers::CustomHandlerException for the description of how args that can augment error messages.
TEST(CustomHandlerException, DirectHttpSample) {
server::http::HttpStatus::kUnprocessableEntity,
server::handlers::ExternalBody{"The provided password is too short"});
server::http::HttpStatus::kUnprocessableEntity);
EXPECT_EQ(exc.GetExternalErrorBody(), "The provided password is too short");
EXPECT_THAT(exc.what(), testing::HasSubstr("Client error"));
}

Definition at line 43 of file http_error.hpp.

Member Function Documentation

◆ GetCode()

HandlerErrorCode server::handlers::CustomHandlerException::GetCode ( ) const
inlineinherited

Definition at line 294 of file exceptions.hpp.

◆ GetDetails()

const formats::json::Value & server::handlers::CustomHandlerException::GetDetails ( ) const
inlineinherited

Definition at line 306 of file exceptions.hpp.

◆ GetExternalErrorBody()

const std::string & server::handlers::CustomHandlerException::GetExternalErrorBody ( ) const
inlineinherited

Definition at line 302 of file exceptions.hpp.

◆ GetExtraHeaders()

const Headers & server::handlers::CustomHandlerException::GetExtraHeaders ( ) const
inlineinherited

Definition at line 308 of file exceptions.hpp.

◆ GetHttpStatus()

HttpStatus server::http::CustomHandlerException::GetHttpStatus ( ) const
inline

Definition at line 49 of file http_error.hpp.

◆ GetServiceCode()

const std::string & server::handlers::CustomHandlerException::GetServiceCode ( ) const
inlineinherited

Definition at line 296 of file exceptions.hpp.

◆ IsExternalErrorBodyFormatted()

bool server::handlers::CustomHandlerException::IsExternalErrorBodyFormatted ( ) const
inlineinherited

Definition at line 298 of file exceptions.hpp.


The documentation for this class was generated from the following file: