mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 20:35:36 +00:00
refactor: remove the tr_error** idiom (#6198)
* refactor: remove the tr_error** idiom * fix: tr_error::message() is only constexpr in c++20 and up * chore: silence a couple of g++-12 Wshadow warnings
This commit is contained in:
12
cli/cli.cc
12
cli/cli.cc
@@ -245,12 +245,14 @@ int tr_main(int argc, char* argv[])
|
||||
|
||||
if (!tr_sys_path_exists(sz_download_dir))
|
||||
{
|
||||
tr_error* error = nullptr;
|
||||
|
||||
if (!tr_sys_dir_create(sz_download_dir, TR_SYS_DIR_CREATE_PARENTS, 0700, &error))
|
||||
if (auto error = tr_error{}; !tr_sys_dir_create(sz_download_dir, TR_SYS_DIR_CREATE_PARENTS, 0700, &error) && error)
|
||||
{
|
||||
fprintf(stderr, "Unable to create download directory \"%s\": %s\n", sz_download_dir.c_str(), error->message);
|
||||
tr_error_free(error);
|
||||
auto const errmsg = fmt::format(
|
||||
"Couldn't create '{path}': {error} ({error_code})",
|
||||
fmt::arg("path", sz_download_dir),
|
||||
fmt::arg("error", error.message()),
|
||||
fmt::arg("error_code", error.code()));
|
||||
fmt::print(stderr, "{:s}\n", errmsg);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user