-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
34 lines (28 loc) · 1.16 KB
/
main.cpp
File metadata and controls
34 lines (28 loc) · 1.16 KB
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
#include "failure_source.h"
#include "flights_err.h"
#include "seats_err.h"
#include <iostream>
void handle_errors(const std::error_code& ec)
{
std::error_condition err_cond;
if (ec == flightservice::FailureSource::BadUserInput) {
err_cond = flightservice::FailureSource::BadUserInput;
} else if (ec == flightservice::FailureSource::InternalError) {
err_cond = flightservice::FailureSource::InternalError;
} else if (ec == flightservice::FailureSource::NoSolution) {
err_cond = flightservice::FailureSource::NoSolution;
}
std::cout << " FailureSource message: " << err_cond.message() << std::endl;
}
int main()
{
std::error_code flights_err = flightservice::FlightsErr::NonexistentLocations;
std::cout << flights_err << std::endl;
std::cout << " value: " << flights_err.value() << " msg: " << flights_err.message() << std::endl;
handle_errors(flights_err);
std::error_code seats_err = flightservice::SeatsErr::NoSeatAvailable;
std::cout << seats_err << std::endl;
std::cout << " value: " << seats_err.value() << " msg: " << seats_err.message() << std::endl;
handle_errors(seats_err);
return 0;
}