Browse Source

own exceptions

synchronous
Volker Birk 5 years ago
parent
commit
d9b43a4c1b
  1. 4
      passphrase_cache.cc
  2. 5
      passphrase_cache.hh

4
passphrase_cache.cc

@ -51,12 +51,12 @@ namespace pEp {
if (_cache.empty()) {
_which = _cache.end();
throw std::underflow_error("empty passphrase cache");
throw Empty();
}
if (_which == _cache.begin()) {
_which = _cache.end();
throw std::underflow_error("out of passphrases");
throw Exhausted();
}
--_which;

5
passphrase_cache.hh

@ -31,6 +31,11 @@ namespace pEp {
cache::iterator _which;
public:
struct Empty : public std::underflow_error {
Empty() : std::underflow_error("passphrase cache empty") { }
struct Exhausted : public std::underflow_error {
Exhausted() : std::underflow_error("out of passphrases") { }
PassphraseCache(int max_size=20, duration timeout =
std::chrono::minutes(10)) : _max_size(max_size),
_timeout(timeout), _which(_cache.end()) { }

Loading…
Cancel
Save