1
0
forked from cheng/wallet

cleaning up error reporting

This commit is contained in:
Cheng 2023-09-22 12:10:52 +10:00
parent ac7f6806eb
commit d7c06c75c0
No known key found for this signature in database
GPG Key ID: 571C3A9C3B9E6FCA
3 changed files with 7 additions and 12 deletions

@ -1 +1 @@
Subproject commit 914033d2c70831b86e94a25f27e61a94bc7d45c8 Subproject commit b6e1e94cfb3d8dffdb1bb92b6102e5fad5fe6093

View File

@ -19,11 +19,12 @@ private:
public: public:
virtual ~MyException() override = default; virtual ~MyException() override = default;
MyException() = delete; MyException() = delete;
explicit MyException(const std::string &m) noexcept :err(m.c_str()),err_number(-1){}
explicit MyException(const char* sz) noexcept :err(sz),err_number(-1) {} 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) noexcept :err(sz), err_number(i) {}
explicit MyException(const char* sz, int i, const char*, const char*) noexcept; explicit MyException(const char* sz, int i, const char*, const char*) noexcept;
// usage throw MyException("error", __LINE__, __func__, __FILE__); // 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; explicit MyException(int, sqlite3*) noexcept;
virtual const char* what() const override { virtual const char* what() const override {
return err.c_str(); return err.c_str();

View File

@ -270,28 +270,22 @@ static bool CheckForUtfEnvironment(void) {
wxString utfError{ wxT("") }; wxString utfError{ wxT("") };
if constexpr (b_WINDOWS) { if constexpr (b_WINDOWS) {
auto ACP{ GetACP() }; auto ACP{ GetACP() };
// Check that windows thinks this is UTF8
utfEnvironment = utfEnvironment && (ACP == 65001); utfEnvironment = utfEnvironment && (ACP == 65001);
if (!utfEnvironment) { if (!utfEnvironment) {
utfError += wxString::Format(wxT("current code page %d—should be 65001☹, "), ACP); utfError += wxString::Format(wxT("current code page %d—should be 65001☹, "), ACP);
} }
} }
auto FontEncoding{ wxLocale::GetSystemEncoding() }; auto FontEncoding{ wxLocale::GetSystemEncoding() };
utfEnvironment = utfEnvironment && (false // check that wxWidgets thinks this is UTF8
|| (FontEncoding == wxFONTENCODING_UTF8) utfEnvironment = utfEnvironment && (FontEncoding == wxFONTENCODING_UTF8);
|| (FontEncoding == wxFONTENCODING_UTF16BE)
|| (FontEncoding == wxFONTENCODING_UTF16LE)
|| (FontEncoding == wxFONTENCODING_UTF32BE)
|| (FontEncoding == wxFONTENCODING_UTF32LE)
|| (FontEncoding == wxFONTENCODING_SYSTEM)
);
if (!utfEnvironment) { if (!utfEnvironment) {
utfError = wxString::Format(wxT("%swxFontEncoding %d—should be %d☹"), utfError = wxString::Format(wxT("%swxFontEncoding %d—should be %d☹"),
utfError, utfError,
FontEncoding, FontEncoding,
wxFONTENCODING_UTF8); wxFONTENCODING_UTF8);
wxLogMessage(wxT("%s"), utfError); throw MyException(utfError.c_str(), __LINE__, __func__, SrcFilename);
} }
if (!utfEnvironment) { throw MyException(utfError); }
} }
catch (const MyException& e) { catch (const MyException& e) {
errorCode = e.what_num(); errorCode = e.what_num();