Kurlyk
Toggle main menu visibility
Loading...
Searching...
No Matches
ClientErrorCategory.hpp
Go to the documentation of this file.
1
#pragma once
2
#ifndef _KURLYK_UTILS_CLIENT_ERROR_CATEGORY_HPP_INCLUDED
3
#define _KURLYK_UTILS_CLIENT_ERROR_CATEGORY_HPP_INCLUDED
4
7
8
namespace
kurlyk::utils
{
9
12
enum class
ClientError
{
13
CancelledByUser
= 1,
14
AbortedDuringDestruction
,
15
ClientNotInitialized
,
16
InvalidConfiguration
,
17
NotConnected
,
18
QueueLimitExceeded
,
19
ShuttingDown
,
20
};
21
24
class
ClientErrorCategory
:
public
std::error_category {
25
public
:
26
const
char
*
name
() const noexcept
override
{
27
return
"http_client"
;
28
}
29
30
std::string
message
(
int
ev)
const override
{
31
switch
(
static_cast<
ClientError
>
(ev)) {
32
case
ClientError::CancelledByUser
:
33
return
"Request was cancelled by the user"
;
34
case
ClientError::AbortedDuringDestruction
:
35
return
"Request was aborted due to handler destruction"
;
36
case
ClientError::ClientNotInitialized
:
37
return
"Client was not initialized properly"
;
38
case
ClientError::InvalidConfiguration
:
39
return
"Invalid or missing client configuration"
;
40
case
ClientError::NotConnected
:
41
return
"Operation failed: client is not connected"
;
42
case
ClientError::QueueLimitExceeded
:
43
return
"Operation was rejected because the queue limit was exceeded"
;
44
case
ClientError::ShuttingDown
:
45
return
"Operation was rejected because the client is shutting down"
;
46
default
:
47
return
"Unknown HTTP client error"
;
48
}
49
}
50
};
51
54
inline
const
std::error_category&
client_error_category
() {
55
static
ClientErrorCategory
instance;
56
return
instance;
57
}
58
62
inline
std::error_code
make_error_code
(
ClientError
e) {
63
return
{
static_cast<
int
>
(e),
client_error_category
()};
64
}
65
66
}
// namespace kurlyk::utils
67
69
namespace
std
{
70
template
<>
71
struct
is_error_code_enum<
kurlyk
::utils::ClientError> : true_type {};
72
}
73
74
#endif
// _KURLYK_UTILS_CLIENT_ERROR_CATEGORY_HPP_INCLUDED
kurlyk::utils::ClientErrorCategory
Custom std::error_category for reporting internal client errors not tied to specific protocols (e....
Definition
ClientErrorCategory.hpp:24
kurlyk::utils::ClientErrorCategory::name
const char * name() const noexcept override
Definition
ClientErrorCategory.hpp:26
kurlyk::utils::ClientErrorCategory::message
std::string message(int ev) const override
Definition
ClientErrorCategory.hpp:30
kurlyk::utils
Definition
Base64Url.hpp:13
kurlyk::utils::ClientError
ClientError
Defines errors related to the internal state or lifecycle of the HTTP/WebSocket client.
Definition
ClientErrorCategory.hpp:12
kurlyk::utils::ClientError::ShuttingDown
@ ShuttingDown
Operation was rejected because the owning subsystem is shutting down.
Definition
ClientErrorCategory.hpp:19
kurlyk::utils::ClientError::NotConnected
@ NotConnected
Operation requires an active connection but none exists.
Definition
ClientErrorCategory.hpp:17
kurlyk::utils::ClientError::AbortedDuringDestruction
@ AbortedDuringDestruction
Request handler was destroyed before completion, causing the request to abort.
Definition
ClientErrorCategory.hpp:14
kurlyk::utils::ClientError::QueueLimitExceeded
@ QueueLimitExceeded
Operation was rejected because the bounded queue is already full.
Definition
ClientErrorCategory.hpp:18
kurlyk::utils::ClientError::ClientNotInitialized
@ ClientNotInitialized
Operation attempted before client was properly initialized.
Definition
ClientErrorCategory.hpp:15
kurlyk::utils::ClientError::CancelledByUser
@ CancelledByUser
Request was cancelled explicitly by the user via cancel().
Definition
ClientErrorCategory.hpp:13
kurlyk::utils::ClientError::InvalidConfiguration
@ InvalidConfiguration
Provided configuration is incomplete or invalid.
Definition
ClientErrorCategory.hpp:16
kurlyk::utils::client_error_category
const std::error_category & client_error_category()
Returns the singleton instance of the ClientErrorCategory.
Definition
ClientErrorCategory.hpp:54
kurlyk::utils::make_error_code
std::error_code make_error_code(ClientError e)
Creates a std::error_code from a ClientError value.
Definition
ClientErrorCategory.hpp:62
kurlyk
Primary namespace for the Kurlyk library, encompassing initialization, request management,...
std
Enables use of ClientError with std::error_code.
Definition
ClientErrorCategory.hpp:69
include
kurlyk
utils
ClientErrorCategory.hpp
Generated by
1.17.0