spank-olm

WIP Do not look
git clone git://archive.git.mtrnord.blog/MTRNord/spank-olm.git
Log | Files | Refs | README | LICENSE

errors.hpp (1611B)


      1 #pragma once
      2 
      3 #include <exception>
      4 #include <string>
      5 #include <utility>
      6 
      7 // Base exception class for SpankOlm
      8 class SpankOlmException : public std::exception
      9 {
     10 public:
     11     explicit SpankOlmException(std::string message) : message_(std::move(message))
     12     {
     13     }
     14 
     15     [[nodiscard]] const char* what() const noexcept override
     16     {
     17         return message_.c_str();
     18     }
     19 
     20 private:
     21     std::string message_;
     22 };
     23 
     24 // Specific exception for key generation errors
     25 class SpankOlmErrorKeyGeneration final : public SpankOlmException
     26 {
     27 public:
     28     SpankOlmErrorKeyGeneration() : SpankOlmException("Error generating key pair.")
     29     {
     30     }
     31 };
     32 
     33 // Specific exception for unknown pickle version errors
     34 class SpankOlmErrorUnknownPickleVersion final : public SpankOlmException
     35 {
     36 public:
     37     SpankOlmErrorUnknownPickleVersion() : SpankOlmException("Unknown pickle version.")
     38     {
     39     }
     40 };
     41 
     42 // Specific exception for not finding the version in the pickle
     43 class SpankOlmErrorVersionNotFound final : public SpankOlmException
     44 {
     45 public:
     46     SpankOlmErrorVersionNotFound() : SpankOlmException("Version not found in pickle.")
     47     {
     48     }
     49 };
     50 
     51 // Specific exception for a bad legacy account pickle
     52 class SpankOlmErrorBadLegacyAccountPickle final : public SpankOlmException
     53 {
     54 public:
     55     SpankOlmErrorBadLegacyAccountPickle() : SpankOlmException("Bad legacy account pickle.")
     56     {
     57     }
     58 };
     59 
     60 // Specific exception for a corrupted account pickle
     61 class SpankOlmErrorCorruptedAccountPickle final : public SpankOlmException
     62 {
     63 public:
     64     SpankOlmErrorCorruptedAccountPickle() : SpankOlmException("Corrupted account pickle.")
     65     {
     66     }
     67 };