mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
feat(core): Add error parsing for Tox_Err_Options_New
This commit is contained in:
parent
a5660fb6e3
commit
2a2b079992
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "src/core/icoresettings.h"
|
||||
#include "src/core/toxlogger.h"
|
||||
#include "util/toxcoreerrorparser.h"
|
||||
|
||||
#include <tox/tox.h>
|
||||
|
||||
|
@ -69,9 +70,10 @@ ToxOptions::operator Tox_Options*()
|
|||
std::unique_ptr<ToxOptions> ToxOptions::makeToxOptions(const QByteArray& savedata,
|
||||
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";
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -58,4 +58,5 @@ namespace ToxcoreErrorParser {
|
|||
bool parseErr(Toxav_Err_Bit_Rate_Set error, int line);
|
||||
bool parseErr(Toxav_Err_Call_Control error, int line);
|
||||
bool parseErr(Toxav_Err_Call error, int line);
|
||||
bool parseErr(Tox_Err_Options_New error, int line);
|
||||
} // namespace ToxcoreErrorParser
|
||||
|
|
|
@ -629,3 +629,17 @@ bool ToxcoreErrorParser::parseErr(Toxav_Err_Call error, int line)
|
|||
qCritical() << line << "Unknown Toxav_Err_Call error code:" << error;
|
||||
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…
Reference in New Issue
Block a user