userver
C++ Async Framework
Toggle main menu visibility
Documentation
API Groups
Namespaces
Reference
Class List
Class Index
File List
Macros
All
e
i
l
r
t
u
Functions
Macros
e
i
l
r
t
u
Examples
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
Concepts
Loading...
Searching...
No Matches
http_error.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/server/http/http_error.hpp
4
/// @brief @copybrief server::http::GetHttpStatus
5
6
#
include
<
stdexcept
>
7
#
include
<
string
>
8
9
#
include
<
userver
/
server
/
handlers
/
exceptions
.
hpp
>
10
#
include
<
userver
/
server
/
http
/
http_status
.
hpp
>
11
12
USERVER_NAMESPACE_BEGIN
13
14
namespace
server::
http
{
15
16
/**
17
* @brief Get http status code mapped to generic handler error code.
18
*
19
* If there is no explicit mapping in the http_error.cpp, will return
20
* HttpStatus::kBadRequest for code values less than
21
* HandlerErrorCode::kServerSideError and will return
22
* HttpStatus::kInternalServerError for the rest of codes.
23
*/
24
HttpStatus
GetHttpStatus
(handlers::
HandlerErrorCode
)
noexcept
;
25
26
/// For server::http::CustomHandlerException, uses the provided HttpStatus.
27
/// For a generic server::handler::CustomHandlerException, converts its
28
/// server::handler::HandlerErrorCode to HttpStatus.
29
HttpStatus
GetHttpStatus
(
const
handlers::
CustomHandlerException
& exception)
noexcept
;
30
31
/// @brief An extension of server::handlers::CustomHandlerException that allows
32
/// to specify a custom HttpStatus.
33
///
34
/// For non-HTTP protocols, the status code will be derived from the attached
35
/// server::handlers::HandlerErrorCode.
36
class
CustomHandlerException
:
public
handlers::
CustomHandlerException
{
37
public
:
38
/// @see server::handlers::CustomHandlerException for the description of how
39
/// `args` that can augment error messages.
40
/// @snippet server/handlers/exceptions_test.cpp Sample construction HTTP
41
template
<
typename
... Args>
42
CustomHandlerException
(handlers::
HandlerErrorCode
error_code, HttpStatus http_status, Args&&... args)
43
: handlers::
CustomHandlerException
(error_code, std::forward<Args>(args)...), http_status_(http_status) {}
42
CustomHandlerException
(handlers::
HandlerErrorCode
error_code, HttpStatus http_status, Args&&... args) {
…
}
44
45
HttpStatus GetHttpStatus()
const
{
return
http_status_; }
46
47
private
:
48
HttpStatus http_status_;
49
};
36
class
CustomHandlerException
:
public
handlers::
CustomHandlerException
{
…
};
50
51
}
// namespace server::http
52
53
USERVER_NAMESPACE_END
userver
server
http
http_error.hpp
Generated on Wed Apr 30 2025 15:54:27 for userver by
Doxygen
1.13.2