| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | #ifndef LRU_INTERNAL_ERRORS_HPP |
| | #define LRU_INTERNAL_ERRORS_HPP |
| |
|
| | #include <stdexcept> |
| | #include <string> |
| |
|
| | namespace LRU { |
| | namespace Error { |
| |
|
| | |
| | struct KeyNotFound : public std::runtime_error { |
| | using super = std::runtime_error; |
| |
|
| | KeyNotFound() : super("Failed to find key") { |
| | } |
| |
|
| | explicit KeyNotFound(const std::string& key) |
| | : super("Failed to find key: " + key) { |
| | } |
| | }; |
| |
|
| | |
| | struct KeyExpired : public std::runtime_error { |
| | using super = std::runtime_error; |
| |
|
| | explicit KeyExpired(const std::string& key) |
| | : super("Key found, but expired: " + key) { |
| | } |
| |
|
| | KeyExpired() : super("Key found, but expired") { |
| | } |
| | }; |
| |
|
| | |
| | struct EmptyCache : public std::runtime_error { |
| | using super = std::runtime_error; |
| | explicit EmptyCache(const std::string& what_was_expected) |
| | : super("Requested " + what_was_expected + " of empty cache") { |
| | } |
| | }; |
| |
|
| | |
| | |
| | struct InvalidIteratorConversion : public std::runtime_error { |
| | using super = std::runtime_error; |
| | InvalidIteratorConversion() |
| | : super("Cannot convert past-the-end unordered to ordered iterator") { |
| | } |
| | }; |
| |
|
| | |
| | struct InvalidIterator : public std::runtime_error { |
| | using super = std::runtime_error; |
| | InvalidIterator() : super("Past-the-end iterator is invalid here") { |
| | } |
| | }; |
| |
|
| | |
| | struct UnmonitoredKey : public std::runtime_error { |
| | using super = std::runtime_error; |
| | UnmonitoredKey() : super("Requested statistics for unmonitored key") { |
| | } |
| | }; |
| |
|
| | |
| | |
| | struct NotMonitoring : public std::runtime_error { |
| | using super = std::runtime_error; |
| | NotMonitoring() : super("Statistics monitoring not enabled for this cache") { |
| | } |
| | }; |
| |
|
| | namespace Lowercase { |
| | using key_not_found = KeyNotFound; |
| | using key_expired = KeyExpired; |
| | using empty_cache = EmptyCache; |
| | using invalid_iterator_conversion = InvalidIteratorConversion; |
| | using invalid_iterator = InvalidIterator; |
| | using unmonitored_key = UnmonitoredKey; |
| | using not_monitoring = NotMonitoring; |
| | } |
| |
|
| | } |
| | } |
| |
|
| | #endif |
| |
|