Kurlyk
Loading...
Searching...
No Matches
CurlErrorCategory.hpp
Go to the documentation of this file.
1#pragma once
2#ifndef KURLYK_HEADER_KURLYK_UTILS_CURL_ERROR_CATEGORY_HPP_INCLUDED
3#define KURLYK_HEADER_KURLYK_UTILS_CURL_ERROR_CATEGORY_HPP_INCLUDED
4
7
8namespace kurlyk {
9namespace utils {
10
13 class CurlErrorCategory : public std::error_category {
14 public:
17 const char* name() const noexcept override {
18 return "curl";
19 }
20
24 std::string message(int ev) const override {
25 return curl_easy_strerror(static_cast<CURLcode>(ev));
26 }
27 };
28
32 inline std::error_code make_error_code(CURLcode e) {
33 static CurlErrorCategory category;
34 return {static_cast<int>(e), category};
35 }
36
37} // namespace utils
38} // namespace kurlyk
39
40#endif // KURLYK_HEADER_KURLYK_UTILS_CURL_ERROR_CATEGORY_HPP_INCLUDED
Represents a custom error category for CURL errors, enabling integration with std::error_code.
const char * name() const noexcept override
Returns the name of the error category.
std::string message(int ev) const override
Returns a descriptive error message for a given CURL error code.
std::error_code make_error_code(ClientError e)
Creates a std::error_code from a ClientError value.
Primary namespace for the Kurlyk library, encompassing initialization, request management,...