syncthingtray/syncthingwidgets/misc/internalerror.h
Martchus 13730ab933 Ignore "Forbidden" errors shortly after Syncthing start
Not sure why I'm getting

```
Fehler beim Abfragen der Syncthing-Konfiguration: Error transferring http://127.0.0.1:8384/rest/system/config - server replied: Forbidden
URL der Anfrage: http://127.0.0.1:8384/rest/system/config
```

one one of my setups but this kind of error can likely be ignored shortly
after the start similar to other types of errors.
2023-06-30 12:43:06 +02:00

48 lines
1.2 KiB
C++

#ifndef SYNCTHINGWIDGETS_INTERNAL_ERROR_H
#define SYNCTHINGWIDGETS_INTERNAL_ERROR_H
#include "../global.h"
#include <c++utilities/chrono/datetime.h>
#include <QByteArray>
#include <QString>
#include <QUrl>
namespace Data {
class SyncthingConnection;
enum class SyncthingErrorCategory;
} // namespace Data
namespace QtGui {
struct SYNCTHINGWIDGETS_EXPORT InternalError {
explicit InternalError(const QString &message = QString(), const QUrl &url = QUrl(), const QByteArray &response = QByteArray());
static bool isRelevant(
const Data::SyncthingConnection &connection, Data::SyncthingErrorCategory category, const QString &message, int networkError);
QString message;
QUrl url;
QByteArray response;
CppUtilities::DateTime when;
};
/*!
* \brief Constructs a new error suitable for display purposes (password in \a url is redacted).
*/
inline InternalError::InternalError(const QString &message, const QUrl &url, const QByteArray &response)
: message(message)
, url(url)
, response(response)
, when(CppUtilities::DateTime::now())
{
if (!this->url.password().isEmpty()) {
this->url.setPassword(QStringLiteral("redacted"));
}
}
} // namespace QtGui
#endif // SYNCTHINGWIDGETS_INTERNAL_ERROR_H