Kurlyk
Loading...
Searching...
No Matches
CurlErrorCategory.hpp
Go to the documentation of this file.
1#pragma once
2#ifndef _KURLYK_UTILS_CURL_ERROR_CATEGORY_HPP_INCLUDED
3#define _KURLYK_UTILS_CURL_ERROR_CATEGORY_HPP_INCLUDED
4
7
8namespace kurlyk::utils {
9
12 class CurlErrorCategory : public std::error_category {
13 public:
16 const char* name() const noexcept override {
17 return "curl";
18 }
19
23 std::string message(int ev) const override {
24 return curl_easy_strerror(static_cast<CURLcode>(ev));
25 }
26 };
27
31 inline std::error_code make_error_code(CURLcode e) {
32 static CurlErrorCategory category;
33 return {static_cast<int>(e), category};
34 }
35
36} // namespace kurlyk::utils
37
38#endif // _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.