1
0
forked from cheng/wallet
wallet/src/ILog.h
2022-06-30 16:55:37 +10:00

89 lines
2.5 KiB
C++

#pragma once
extern int errorCode;
extern std::string szError;
void ILogFatalError(const char*);
void ILogError(const char*);
void ILogWarning(const char*);
void ILogMessage(const char* format);
void ILogVerbose(const char*);
void ILogDebug(const char*);
void queue_error_message(const char*); //Used for error conditions within a destructor because you cannot throw within a destructor
void queue_fatal_error(const char*); //Used for fatal error conditions within a destructor in place of FatalException because you cannot throw within a destructor
class MyException: public std::exception {
private:
std::string err;
public:
virtual ~MyException() override = default;
MyException() = delete;
explicit MyException(const std::string &m) noexcept :err(m){}
explicit MyException(const char* sz) noexcept :err(sz) {}
virtual const char* what() const override {
return err.c_str();
}
};
class FatalException : public MyException {
public:
using MyException::MyException;
FatalException() noexcept;
};
class HashReuseException : public MyException {
public:
using MyException::MyException;
HashReuseException() noexcept;
};
class SQLexception : public MyException {
public:
using MyException::MyException;
SQLexception() noexcept;
};
class NonUtf8DataInDatabase : public MyException {
public:
using MyException::MyException;
NonUtf8DataInDatabase() noexcept;
};
class BadDataException : public MyException {
public:
using MyException::MyException;
BadDataException() noexcept;
};
class NonRandomScalarException : public MyException {
public:
using MyException::MyException;
NonRandomScalarException() noexcept;
};
class BadScalarException : public MyException {
public:
using MyException::MyException;
BadScalarException() noexcept;
};
class OversizeBase58String : public MyException {
public:
using MyException::MyException;
OversizeBase58String() noexcept;
};
// This exception is obviously far too generic, because the routine throwing it knows nothing of the context.
// does not know what the cryptographic id identifies.
// higher level code that does know the context needs to catch the exception and issue a more
// relevant errror message, possibly with by more informative rethrow.
class BadStringRepresentationOfCryptoIdException : public MyException {
public:
using MyException::MyException;
BadStringRepresentationOfCryptoIdException() noexcept;
};
class NotBase58Exception : public MyException {
public:
using MyException::MyException;
NotBase58Exception() noexcept;
};