Browse Source

feat(core): Add error parsing for Tox_Err_Options_New

pull/6578/head
Anthony Bilinski 3 years ago
parent
commit
2a2b079992
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
  1. 6
      src/core/toxoptions.cpp
  2. 1
      util/include/util/toxcoreerrorparser.h
  3. 14
      util/src/toxcoreerrorparser.cpp

6
src/core/toxoptions.cpp

@ -21,6 +21,7 @@
#include "src/core/icoresettings.h" #include "src/core/icoresettings.h"
#include "src/core/toxlogger.h" #include "src/core/toxlogger.h"
#include "util/toxcoreerrorparser.h"
#include <tox/tox.h> #include <tox/tox.h>
@ -69,9 +70,10 @@ ToxOptions::operator Tox_Options*()
std::unique_ptr<ToxOptions> ToxOptions::makeToxOptions(const QByteArray& savedata, std::unique_ptr<ToxOptions> ToxOptions::makeToxOptions(const QByteArray& savedata,
const ICoreSettings& s) const ICoreSettings& s)
{ {
Tox_Options* tox_opts = tox_options_new(nullptr); Tox_Err_Options_New err;
Tox_Options* tox_opts = tox_options_new(&err);
if (!tox_opts) { if (!PARSE_ERR(err) || !tox_opts) {
qWarning() << "Failed to create Tox_Options"; qWarning() << "Failed to create Tox_Options";
return {}; return {};
} }

1
util/include/util/toxcoreerrorparser.h

@ -58,4 +58,5 @@ namespace ToxcoreErrorParser {
bool parseErr(Toxav_Err_Bit_Rate_Set error, int line); bool parseErr(Toxav_Err_Bit_Rate_Set error, int line);
bool parseErr(Toxav_Err_Call_Control error, int line); bool parseErr(Toxav_Err_Call_Control error, int line);
bool parseErr(Toxav_Err_Call error, int line); bool parseErr(Toxav_Err_Call error, int line);
bool parseErr(Tox_Err_Options_New error, int line);
} // namespace ToxcoreErrorParser } // namespace ToxcoreErrorParser

14
util/src/toxcoreerrorparser.cpp

@ -629,3 +629,17 @@ bool ToxcoreErrorParser::parseErr(Toxav_Err_Call error, int line)
qCritical() << line << "Unknown Toxav_Err_Call error code:" << error; qCritical() << line << "Unknown Toxav_Err_Call error code:" << error;
return false; return false;
} }
bool ToxcoreErrorParser::parseErr(Tox_Err_Options_New error, int line)
{
switch (error) {
case TOX_ERR_OPTIONS_NEW_OK:
return true;
case TOX_ERR_OPTIONS_NEW_MALLOC:
qCritical() << line << ": Failed to allocate memory.";
return false;
}
qCritical() << line << "Unknown Tox_Err_Options_New error code:" << error;
return false;
}

Loading…
Cancel
Save