error.h
Go to the documentation of this file.
1 #ifndef CPR_ERROR_H
2 #define CPR_ERROR_H
3 
4 #include <cstdint>
5 #include <string>
6 
7 #include "cpr/cprtypes.h"
8 #include "cpr/defines.h"
9 
10 namespace cpr {
11 
12 enum class ErrorCode {
13  OK = 0,
29  UNKNOWN_ERROR = 1000,
30 };
31 
32 class Error {
33  public:
34  Error() : code{ErrorCode::OK} {}
35 
36  template <typename TextType>
37  Error(const std::int32_t& curl_code, TextType&& p_error_message)
38  : code{getErrorCodeForCurlError(curl_code)}, message{CPR_FWD(p_error_message)} {}
39 
40  explicit operator bool() const {
41  return code != ErrorCode::OK;
42  }
43 
46 
47  private:
48  static ErrorCode getErrorCodeForCurlError(std::int32_t curl_code);
49 };
50 
51 } // namespace cpr
52 
53 #endif
ErrorCode code
Definition: error.h:44
::std::string string
Definition: gtest-port.h:1129
Error(const std::int32_t &curl_code, TextType &&p_error_message)
Definition: error.h:37
#define CPR_FWD(...)
Definition: defines.h:6
ErrorCode
Definition: error.h:12
Error()
Definition: error.h:34
std::string message
Definition: error.h:45
Definition: auth.cpp:3


rc_tagdetect_client
Author(s): Monika Florek-Jasinska , Raphael Schaller
autogenerated on Sat Feb 13 2021 03:42:09