Better error handling and safer pointer initialization plus some more fixes

This commit is contained in:
woblight
2019-08-24 00:11:17 +02:00
parent 0c98f06a15
commit ee1550991c
4 changed files with 141 additions and 78 deletions
+35 -1
View File
@@ -1,4 +1,4 @@
/* Copyright 2018 WobLight
/* Copyright 2018-2019 WobLight
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -535,3 +535,37 @@ void Control::setUpdateStatus(Control::UpdateStatus updateStatus)
m_updateStatus = updateStatus;
emit updateStatusChanged(m_updateStatus);
}
#include <execinfo.h>
GitException::GitException(int code) : m_code(code)
{
const git_error *e = giterr_last();
m_errorString = QString::asprintf("Error %d/%d: %s", code, e->klass, e->message);
giterr_clear();
}
int GitException::code()
{
return m_code;
}
QString GitException::errorString() const
{
return m_errorString;
}
void GitException::raise() const
{
throw *this;
}
GitException *GitException::clone() const
{
return new GitException(*this);
}
int check_git_return(int code)
{
if (code < 0 && giterr_last() && code != GIT_ITEROVER && code != GIT_ENOTFOUND) throw GitException(code);
else return code;
}