forked from jmccl/acme-lw
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathacme-exception.cpp
More file actions
36 lines (28 loc) · 772 Bytes
/
Copy pathacme-exception.cpp
File metadata and controls
36 lines (28 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "acme-exception.h"
#include <openssl/err.h>
using namespace std;
namespace acme_lw
{
AcmeException::AcmeException(const string& s)
{
// We assume the error is going to be from openssl. If it's not, we just
// use the string passed in as the error message.
unsigned long err = ERR_get_error();
while (ERR_get_error()); // clear any previous errors we didn't deal with for some reason;
if (err)
{
constexpr int buffSize = 120;
char buffer[buffSize];
ERR_error_string(err, buffer);
what_ = (s.size() ? s + ": " : s) + "OpenSSL error (" + to_string(err) + "): " + buffer;
}
else
{
what_ = s;
}
}
const char * AcmeException::what() const noexcept
{
return what_.c_str();
}
}