mastodonpp  0.3.0
Public Member Functions | Public Attributes | List of all members
mastodonpp::CURLException Class Reference

Exception for libcurl errors. More...

#include <mastodonpp/exceptions.hpp>

Inheritance diagram for mastodonpp::CURLException:

Public Member Functions

 CURLException (const CURLcode &error, string message)
 Constructor with error code and message. More...
 
 CURLException (const CURLcode &error, string message, string error_buffer)
 Constructor with error code, message and error buffer. More...
 
 CURLException (string message)
 Constructor with message. More...
 
const char * what () const noexcept override
 Returns the error code, message and error buffer. More...
 

Public Attributes

const CURLcode error_code
 The error code returned by libcurl. More...
 

Detailed Description

Exception for libcurl errors.

Since
0.1.0

Constructor & Destructor Documentation

◆ CURLException() [1/3]

mastodonpp::CURLException::CURLException ( const CURLcode &  error,
string  message 
)
explicit

Constructor with error code and message.

Since
0.1.0
28  : error_code{error}
29  , _message{move(message)}
30 {}

◆ CURLException() [2/3]

mastodonpp::CURLException::CURLException ( const CURLcode &  error,
string  message,
string  error_buffer 
)
explicit

Constructor with error code, message and error buffer.

Since
0.1.0
34  : error_code{error}
35  , _message{move(message)}
36  , _error_buffer{move(error_buffer)}
37 {}

◆ CURLException() [3/3]

mastodonpp::CURLException::CURLException ( string  message)
explicit

Constructor with message.

Since
0.1.0
40  : error_code{CURLE_OK}
41  , _message{move(message)}
42 {}

Member Function Documentation

◆ what()

const char * mastodonpp::CURLException::what ( ) const
overridenoexcept

Returns the error code, message and error buffer.

Since
0.1.0
45 {
46  static string error_string{"libCURL error: "};
47  if (error_code != CURLE_OK)
48  {
49  error_string += to_string(error_code) + " - ";
50  }
51  error_string += _message;
52  if (!_error_buffer.empty())
53  {
54  error_string += " [" + _error_buffer + "]";
55  }
56  return error_string.c_str();
57 }

Member Data Documentation

◆ error_code

const CURLcode mastodonpp::CURLException::error_code

The error code returned by libcurl.

For more information consult libcurl-errors(3).

Since
0.1.0

The documentation for this class was generated from the following files:
mastodonpp::CURLException::error_code
const CURLcode error_code
The error code returned by libcurl.
Definition: exceptions.hpp:73