From b84bc7895e5d531bf01c316d27aa87151e9eab6d Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Mon, 9 Jan 2023 02:06:49 +0100 Subject: [PATCH] Add some more error logging --- src/ChatPage.cpp | 4 +--- src/encryption/Olm.cpp | 4 ++-- src/ui/UserProfile.cpp | 36 +++++++++++++++--------------------- 3 files changed, 18 insertions(+), 26 deletions(-) diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp index c5d3d012..cf44ae00 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp @@ -1381,9 +1381,7 @@ ChatPage::decryptDownloadedSecrets(mtx::secret_storage::AesHmacSha2KeyDescriptio http::client()->keys_signatures_upload( req, [](const mtx::responses::KeySignaturesUpload &res, mtx::http::RequestErr err) { if (err) { - nhlog::net()->error("failed to upload signatures: {},{}", - mtx::errors::to_string(err->matrix_error.errcode), - static_cast(err->status_code)); + nhlog::net()->error("failed to upload signatures: {}", *err); } for (const auto &[user_id, tmp] : res.errors) diff --git a/src/encryption/Olm.cpp b/src/encryption/Olm.cpp index ea30da4c..f9f31fd5 100644 --- a/src/encryption/Olm.cpp +++ b/src/encryption/Olm.cpp @@ -138,8 +138,8 @@ handle_to_device_messages(const std::vectorquery_keys( olm_msg.sender, [olm_msg](const UserKeyCache &userKeys, mtx::http::RequestErr e) { if (e) { - nhlog::crypto()->error("Failed to query user keys, dropping olm " - "message"); + nhlog::crypto()->error( + "Failed to query user keys, dropping olm message: {}", e); return; } handle_olm_message(std::move(olm_msg), userKeys); diff --git a/src/ui/UserProfile.cpp b/src/ui/UserProfile.cpp index ca222d8b..5f39e35a 100644 --- a/src/ui/UserProfile.cpp +++ b/src/ui/UserProfile.cpp @@ -190,9 +190,7 @@ UserProfile::fetchDeviceList(const QString &userID) [other_user_id = userID.toStdString(), this](const UserKeyCache &, mtx::http::RequestErr err) { if (err) { - nhlog::net()->warn("failed to query device keys: {},{}", - mtx::errors::to_string(err->matrix_error.errcode), - static_cast(err->status_code)); + nhlog::net()->warn("failed to query device keys: {}", *err); } // Ensure local key cache is up to date @@ -203,9 +201,7 @@ UserProfile::fetchDeviceList(const QString &userID) std::string local_user_id = utils::localUser().toStdString(); if (err) { - nhlog::net()->warn("failed to query device keys: {},{}", - mtx::errors::to_string(err->matrix_error.errcode), - static_cast(err->status_code)); + nhlog::net()->warn("failed to query device keys: {}", *err); } emit verificationStatiChanged(); @@ -261,9 +257,7 @@ UserProfile::updateVerificationStatus() [this, deviceInfo](const mtx::responses::QueryDevices &allDevs, mtx::http::RequestErr err) mutable { if (err) { - nhlog::net()->warn("failed to query devices: {} {}", - err->matrix_error.error, - static_cast(err->status_code)); + nhlog::net()->warn("failed to query device keys: {}", *err); this->deviceList_.queueReset(std::move(deviceInfo)); emit devicesChanged(); return; @@ -335,7 +329,7 @@ UserProfile::changeUsername(const QString &username) // change global http::client()->set_displayname(username.toStdString(), [](mtx::http::RequestErr err) { if (err) { - nhlog::net()->warn("could not change username"); + nhlog::net()->warn("could not change username: {}", *err); return; } }); @@ -358,7 +352,7 @@ UserProfile::changeDeviceName(const QString &deviceID, const QString &deviceName http::client()->set_device_name( deviceID.toStdString(), deviceName.toStdString(), [this](mtx::http::RequestErr err) { if (err) { - nhlog::net()->warn("could not change device name"); + nhlog::net()->warn("could not change device name: {}", *err); return; } refreshDevices(); @@ -434,14 +428,14 @@ UserProfile::changeAvatar() room_id = roomid_.toStdString(), content = std::move(bin)](const mtx::responses::ContentURI &res, mtx::http::RequestErr err) { if (err) { - nhlog::ui()->error("Failed to upload image", err->matrix_error.error); + nhlog::ui()->error("Failed to upload image: {}", *err); return; } if (isGlobalUserProfile()) { http::client()->set_avatar_url(res.content_uri, [this](mtx::http::RequestErr err) { if (err) { - nhlog::ui()->error("Failed to set user avatar url", err->matrix_error.error); + nhlog::ui()->error("Failed to set user avatar url: {}", *err); } isLoading_ = false; @@ -463,14 +457,14 @@ UserProfile::changeAvatar() void UserProfile::updateRoomMemberState(mtx::events::state::Member member) { - http::client()->send_state_event( - roomid_.toStdString(), - http::client()->user_id().to_string(), - member, - [](mtx::responses::EventId, mtx::http::RequestErr err) { - if (err) - nhlog::net()->error("Failed to update room member state : ", err->matrix_error.error); - }); + http::client()->send_state_event(roomid_.toStdString(), + http::client()->user_id().to_string(), + member, + [](mtx::responses::EventId, mtx::http::RequestErr err) { + if (err) + nhlog::net()->error( + "Failed to update room member state: {}", *err); + }); } void