Avoid unneeded std::string casts in exception handling

This commit is contained in:
Ilya Fedin 2023-09-19 17:10:53 +04:00 committed by John Preston
parent a54bc449e4
commit e0b4d1edce
4 changed files with 10 additions and 17 deletions

View File

@ -26,8 +26,7 @@ void UnsafeOpenUrl(const QString &url) {
base::Platform::AppLaunchContext());
if (!result) {
LOG(("App Error: %1").arg(
QString::fromStdString(result.error().what())));
LOG(("App Error: %1").arg(result.error().what()));
} else if (*result) {
return;
}
@ -52,8 +51,7 @@ void UnsafeLaunch(const QString &filepath) {
if ([&] {
const auto filename = GLib::filename_to_uri(filepath.toStdString());
if (!filename) {
LOG(("App Error: %1").arg(
QString::fromStdString(filename.error().what())));
LOG(("App Error: %1").arg(filename.error().what()));
return false;
}
@ -63,8 +61,7 @@ void UnsafeLaunch(const QString &filepath) {
base::Platform::AppLaunchContext());
if (!result) {
LOG(("App Error: %1").arg(
QString::fromStdString(result.error().what())));
LOG(("App Error: %1").arg(result.error().what()));
return false;
}

View File

@ -174,7 +174,7 @@ gi::ref_ptr<Application> MakeApplication() {
const auto result = gi::make_ref<Application>();
if (const auto registered = result->register_(); !registered) {
LOG(("App Error: Failed to register: %1").arg(
QString::fromStdString(registered.error().message_())));
registered.error().message_().c_str()));
return nullptr;
}
return result;

View File

@ -58,8 +58,7 @@ void Noexcept(Fn<void()> callback, Fn<void()> failed = nullptr) noexcept {
callback();
return;
} catch (const std::exception &e) {
LOG(("Native Notification Error: %1").arg(
QString::fromStdString(e.what())));
LOG(("Native Notification Error: %1").arg(e.what()));
}
if (failed) {

View File

@ -68,8 +68,7 @@ void PortalAutostart(bool enabled, Fn<void(bool)> done) {
Gio::DBus::BusType::SESSION);
} catch (const std::exception &e) {
if (done) {
LOG(("Portal Autostart Error: %1").arg(
QString::fromStdString(e.what())));
LOG(("Portal Autostart Error: %1").arg(e.what()));
}
return Glib::RefPtr<Gio::DBus::Connection>();
}
@ -144,8 +143,7 @@ void PortalAutostart(bool enabled, Fn<void(bool)> done) {
}
} catch (const std::exception &e) {
if (done) {
LOG(("Portal Autostart Error: %1").arg(
QString::fromStdString(e.what())));
LOG(("Portal Autostart Error: %1").arg(e.what()));
done(false);
}
}
@ -174,8 +172,7 @@ void PortalAutostart(bool enabled, Fn<void(bool)> done) {
connection->call_finish(result);
} catch (const std::exception &e) {
if (done) {
LOG(("Portal Autostart Error: %1").arg(
QString::fromStdString(e.what())));
LOG(("Portal Autostart Error: %1").arg(e.what()));
done(false);
}
@ -286,7 +283,7 @@ bool GenerateDesktopFile(
target->save_to_file(targetFile.toStdString());
} catch (const std::exception &e) {
if (!silent) {
LOG(("App Error: %1").arg(QString::fromStdString(e.what())));
LOG(("App Error: %1").arg(e.what()));
}
return false;
}
@ -378,7 +375,7 @@ bool GenerateServiceFile(bool silent = false) {
target->save_to_file(targetFile.toStdString());
} catch (const std::exception &e) {
if (!silent) {
LOG(("App Error: %1").arg(QString::fromStdString(e.what())));
LOG(("App Error: %1").arg(e.what()));
}
return false;
}