nicehash-api-cpp  0.0.1
throwExceptionIfLocationInvalid.cpp
Go to the documentation of this file.
1 #include <stdexcept>
2 #include <set>
3 
4 #include "../../include/nicehash-api.hpp"
5 
6 
7 /**
8  * \brief Throw an exception if the location id is invalid
9  *
10  * Throw a std::invalid_argument exception if the location id is invalid.
11  * Valid location ids can be found here https://www.nicehash.com/?p=api
12  * Currently there are only two locations (0, 1) but this may change in the
13  * future, so this function is here for flexibility later (but currently a bit overkill).
14  *
15  */
16 void NiceHashApi::throwExceptionIfLocationInvalid (int location_id) {
17  const std::set<int> valid_location_ids = { 0, 1 };
18 
19  const bool location_id_is_valid = valid_location_ids.count(location_id);
20 
21  if (!location_id_is_valid)
22  throw std::invalid_argument("Location ID is invalid");
23 }
24