Cleanup error logging a bit

This commit is contained in:
Nicolas Werner 2021-11-29 06:20:43 +01:00
parent 6779f0e509
commit 6266c917c0
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9

View file

@ -213,9 +213,7 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
"", "",
[this](const mtx::responses::Notifications &res, mtx::http::RequestErr err) { [this](const mtx::responses::Notifications &res, mtx::http::RequestErr err) {
if (err) { if (err) {
nhlog::net()->warn("failed to retrieve notifications: {} ({})", nhlog::net()->warn("failed to retrieve notifications: {}", err);
err->matrix_error.error,
static_cast<int>(err->status_code));
return; return;
} }
@ -509,8 +507,7 @@ ChatPage::tryInitialSync()
return startInitialSync(); return startInitialSync();
} }
nhlog::crypto()->critical( nhlog::crypto()->critical("failed to upload one time keys: {}", err);
"failed to upload one time keys: {} {}", err->matrix_error.error, status_code);
QString errorMsg(tr("Failed to setup encryption keys. Server response: " QString errorMsg(tr("Failed to setup encryption keys. Server response: "
"%1 %2. Please try again later.") "%1 %2. Please try again later.")
@ -550,11 +547,7 @@ ChatPage::startInitialSync()
const auto err_code = mtx::errors::to_string(err->matrix_error.errcode); const auto err_code = mtx::errors::to_string(err->matrix_error.errcode);
const int status_code = static_cast<int>(err->status_code); const int status_code = static_cast<int>(err->status_code);
nhlog::net()->error("initial sync error: {} {} {} {}", nhlog::net()->error("initial sync error: {}", err);
err->parse_error,
status_code,
err->error_code,
err_code);
// non http related errors // non http related errors
if (status_code <= 0 || status_code >= 600) { if (status_code <= 0 || status_code >= 600) {
@ -727,11 +720,10 @@ ChatPage::createRoom(const mtx::requests::CreateRoom &req)
http::client()->create_room( http::client()->create_room(
req, [this](const mtx::responses::CreateRoom &res, mtx::http::RequestErr err) { req, [this](const mtx::responses::CreateRoom &res, mtx::http::RequestErr err) {
if (err) { if (err) {
const auto err_code = mtx::errors::to_string(err->matrix_error.errcode); const auto err_code = mtx::errors::to_string(err->matrix_error.errcode);
const auto error = err->matrix_error.error; const auto error = err->matrix_error.error;
const int status_code = static_cast<int>(err->status_code);
nhlog::net()->warn("failed to create room: {} {} ({})", error, err_code, status_code); nhlog::net()->warn("failed to create room: {})", err);
emit showNotification( emit showNotification(
tr("Room creation failed: %1").arg(QString::fromStdString(error))); tr("Room creation failed: %1").arg(QString::fromStdString(error)));
@ -927,10 +919,7 @@ ChatPage::verifyOneTimeKeyCountAfterStartup()
olm::client()->create_upload_keys_request(), olm::client()->create_upload_keys_request(),
[this](const mtx::responses::UploadKeys &res, mtx::http::RequestErr err) { [this](const mtx::responses::UploadKeys &res, mtx::http::RequestErr err) {
if (err) { if (err) {
nhlog::crypto()->warn("failed to update one-time keys: {} {} {}", nhlog::crypto()->warn("failed to update one-time keys: {}", err);
err->matrix_error.error,
static_cast<int>(err->status_code),
static_cast<int>(err->error_code));
if (err->status_code < 400 || err->status_code >= 500) if (err->status_code < 400 || err->status_code >= 500)
return; return;
@ -970,10 +959,7 @@ ChatPage::ensureOneTimeKeyCount(const std::map<std::string, uint16_t> &counts)
olm::client()->create_upload_keys_request(), olm::client()->create_upload_keys_request(),
[](const mtx::responses::UploadKeys &, mtx::http::RequestErr err) { [](const mtx::responses::UploadKeys &, mtx::http::RequestErr err) {
if (err) { if (err) {
nhlog::crypto()->warn("failed to update one-time keys: {} {} {}", nhlog::crypto()->warn("failed to update one-time keys: {}", err);
err->matrix_error.error,
static_cast<int>(err->status_code),
static_cast<int>(err->error_code));
if (err->status_code < 400 || err->status_code >= 500) if (err->status_code < 400 || err->status_code >= 500)
return; return;
@ -990,10 +976,7 @@ ChatPage::ensureOneTimeKeyCount(const std::map<std::string, uint16_t> &counts)
http::client()->claim_keys( http::client()->claim_keys(
req, [](const mtx::responses::ClaimKeys &, mtx::http::RequestErr err) { req, [](const mtx::responses::ClaimKeys &, mtx::http::RequestErr err) {
if (err) if (err)
nhlog::crypto()->warn("failed to clear 1 one-time key: {} {} {}", nhlog::crypto()->warn("failed to clear 1 one-time key: {}", err);
err->matrix_error.error,
static_cast<int>(err->status_code),
static_cast<int>(err->error_code));
else else
nhlog::crypto()->info("cleared 1 one-time key"); nhlog::crypto()->info("cleared 1 one-time key");
}); });
@ -1080,9 +1063,7 @@ ChatPage::initiateLogout()
if (err) { if (err) {
// TODO: handle special errors // TODO: handle special errors
emit contentLoaded(); emit contentLoaded();
nhlog::net()->warn("failed to logout: {} - {}", nhlog::net()->warn("failed to logout: {}", err);
mtx::errors::to_string(err->matrix_error.errcode),
err->matrix_error.error);
return; return;
} }
@ -1200,7 +1181,7 @@ ChatPage::decryptDownloadedSecrets(mtx::secret_storage::AesHmacSha2KeyDescriptio
for (const auto &[user_id, tmp] : res.errors) for (const auto &[user_id, tmp] : res.errors)
for (const auto &[key_id, e] : tmp) for (const auto &[key_id, e] : tmp)
nhlog::net()->error("signature error for user '{}' and key " nhlog::net()->error("signature error for user '{}' and key "
"id {}: {}, {}", "id {}: {} {}",
user_id, user_id,
key_id, key_id,
mtx::errors::to_string(e.errcode), mtx::errors::to_string(e.errcode),