mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:58:12 +00:00
open: Display a meaningful error if the specified file doesn't exist
Previously, the error given for any non-existent file was: "Failed to open ':'".
This commit is contained in:
parent
1f2ab4ebfc
commit
0068e91aad
1 changed files with 11 additions and 2 deletions
|
@ -25,8 +25,17 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
bool all_ok = true;
|
bool all_ok = true;
|
||||||
|
|
||||||
for (auto& url_or_path : urls_or_paths) {
|
for (auto& url_or_path : urls_or_paths) {
|
||||||
auto path = FileSystem::real_path(url_or_path);
|
auto path_or_error = FileSystem::real_path(url_or_path);
|
||||||
auto url = URL::create_with_url_or_path(path.is_error() ? url_or_path : path.value());
|
URL url;
|
||||||
|
if (path_or_error.is_error()) {
|
||||||
|
url = url_or_path;
|
||||||
|
if (!url.is_valid()) {
|
||||||
|
warnln("Failed to open: '{}': {}", url_or_path, strerror(path_or_error.error().code()));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
url = URL::create_with_url_or_path(path_or_error.value().to_deprecated_string());
|
||||||
|
}
|
||||||
|
|
||||||
if (!Desktop::Launcher::open(url)) {
|
if (!Desktop::Launcher::open(url)) {
|
||||||
warnln("Failed to open '{}'", url);
|
warnln("Failed to open '{}'", url);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue