forked from cheng/wallet
bba593180e
sanity test of pubkey mysteriously fails in display_wallet, yet identical test with same values succeeds in unit_test need to create a view once sanity test passes. then need to refresh display on edit/add name need to make a second try at integrating release v3.2.2.1
97 lines
3.2 KiB
C++
97 lines
3.2 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
|
|
|
|
struct sqlite3;
|
|
|
|
class MyException: public std::exception {
|
|
private:
|
|
std::string err;
|
|
int err_number;
|
|
public:
|
|
virtual ~MyException() override = default;
|
|
MyException() = delete;
|
|
explicit MyException(const char* sz) noexcept :err(sz),err_number(-1) {}
|
|
explicit MyException(const std::string& m) noexcept :err(m.c_str()), err_number(-1) {}
|
|
explicit MyException(const char* sz, int i) noexcept :err(sz), err_number(i) {}
|
|
explicit MyException(const char* sz, int i, const char*, const char*) noexcept;
|
|
// usage throw MyException("error", __LINE__, __func__, __FILE__);
|
|
explicit MyException(const std::string& m, int i, const char* func, const char* file) noexcept : MyException(m.c_str(), i, func, file) {}
|
|
explicit MyException(int, sqlite3*) noexcept;
|
|
virtual const char* what() const override {
|
|
return err.c_str();
|
|
}
|
|
virtual const int what_num() const {
|
|
return err_number;
|
|
}
|
|
explicit MyException(MyException e, std::string str)noexcept : err(e.what() + str), err_number(e.what_num()) {}
|
|
explicit MyException(MyException e, int i, const char* func, const char* file) noexcept;
|
|
explicit MyException(std::exception e, int i, const char* func, const char* file) noexcept;
|
|
};
|
|
|
|
class FatalException : public MyException {
|
|
public:
|
|
using MyException::MyException;
|
|
FatalException() noexcept;
|
|
};
|
|
|
|
class HashReuseException : public MyException {
|
|
public:
|
|
using MyException::MyException;
|
|
HashReuseException() 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;
|
|
};
|