-
Notifications
You must be signed in to change notification settings - Fork 2
/
error.h
34 lines (28 loc) · 870 Bytes
/
error.h
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
#ifndef _SBE_APP_ERROR_H_
#define _SBE_APP_ERROR_H_
#include <inttypes.h>
#include <optional>
#include <string>
#include "spot_sbe/ErrorResponse.h"
using spot_sbe::ErrorResponse;
struct Error {
int16_t code;
std::optional<int64_t> server_time;
std::optional<int64_t> retry_after;
std::string msg;
explicit Error(ErrorResponse& decoder)
: code{decoder.code()},
server_time{decoder.serverTime()},
retry_after{decoder.retryAfter()},
msg{decoder.getMsgAsString()} {
if (server_time == ErrorResponse::serverTimeNullValue()) {
server_time.reset();
}
if (retry_after == ErrorResponse::retryAfterNullValue()) {
retry_after.reset();
}
// Field "data" is only used for cancel replace responses so we omit it
// in this example.
}
};
#endif