-
Notifications
You must be signed in to change notification settings - Fork 1
/
seats_err.h
37 lines (28 loc) · 1.17 KB
/
seats_err.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
35
36
37
#pragma once
#include <system_error>
namespace flightservice {
enum class SeatsErr {
// no 0
// 0 represents OK/Success is std::error_code's convention.
// internal error
InvalidRequest = 1, // e.g., bad XML
CouldNotConnect, // could not connect to server
InternalError, // service run short of resources
NoResponse, // did not respond in time
// illogical request
NonexistentClass = 10, // requested class does not exist
// bad luck
NoSeatAvailable = 20, // all seats booked
};
// overload for `std::make_error_code` for SeatsErr.
// http://naipc.uchicago.edu/2014/ref/cppreference/en/cpp/error/error_code/error_code.html
std::error_code make_error_code(flightservice::SeatsErr e) noexcept;
// for category compare in condition checking
const std::error_category& get_seats_err_category() noexcept;
}
// specialize template for SeatsErr to indicate that
// the type is eligible for `std::error_code` and `std::error_condition` automatic conversions.
// http://naipc.uchicago.edu/2014/ref/cppreference/en/cpp/error/error_code/is_error_code_enum.html
template <>
struct std::is_error_code_enum<flightservice::SeatsErr> : public std::true_type {
};