Improve displaying errors

This commit is contained in:
Martchus 2021-05-21 22:35:28 +02:00
parent 7ad82c9dfe
commit 5a39b6bc91
1 changed files with 17 additions and 11 deletions

View File

@ -1,5 +1,7 @@
#include "./internalerrorsdialog.h"
#include <c++utilities/io/ansiescapecodes.h>
#include <QHBoxLayout>
#include <QIcon>
#include <QLabel>
@ -80,20 +82,24 @@ void InternalErrorsDialog::addError(InternalError &&newError)
void InternalErrorsDialog::internalAddError(const InternalError &error)
{
const QString url(error.url.toString());
browser()->append(QString::fromUtf8(error.when.toString(DateTimeOutputFormat::DateAndTime, true).data()) % QChar(':') % QChar(' ') % error.message
% QChar('\n') % m_request % QChar(' ') % url % QChar('\n') % m_response % QChar('\n') % QString::fromLocal8Bit(error.response) % QChar('\n'));
// also log errors to console
cerr << "internal error: " << error.message.toLocal8Bit().data();
if (!error.url.isEmpty()) {
cerr << "\n request URL: " << url.toLocal8Bit().data();
const QString url = error.url.toString();
browser()->append(QString::fromUtf8(error.when.toString(DateTimeOutputFormat::DateAndTime, true).data()) % QChar(':') % QChar(' ') % error.message);
if (!url.isEmpty()) {
browser()->append(m_request % QChar(' ') % url);
}
if (!error.response.isEmpty()) {
cerr << "\n response: " << error.response.data();
browser()->append(m_response % QChar('\n') % QString::fromLocal8Bit(error.response));
}
// also log errors to console
using namespace EscapeCodes;
cerr << Phrases::Error << error.message.toLocal8Bit().data() << Phrases::End;
if (!error.url.isEmpty()) {
cerr << "request URL: " << url.toLocal8Bit().data() << '\n';
}
if (!error.response.isEmpty()) {
cerr << "response: " << error.response.data() << '\n';
}
cerr << endl;
}
void InternalErrorsDialog::updateStatusLabel()