mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03: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
Notes:
sideshowbarker
2024-07-16 21:51:02 +09:00
Author: https://github.com/tcl3 Commit: https://github.com/SerenityOS/serenity/commit/0068e91aad Pull-request: https://github.com/SerenityOS/serenity/pull/21315
@ -25,8 +25,17 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
bool all_ok = true;
|
||||
|
||||
for (auto& url_or_path : urls_or_paths) {
|
||||
auto path = FileSystem::real_path(url_or_path);
|
||||
auto url = URL::create_with_url_or_path(path.is_error() ? url_or_path : path.value());
|
||||
auto path_or_error = FileSystem::real_path(url_or_path);
|
||||
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)) {
|
||||
warnln("Failed to open '{}'", url);
|
||||
|
Loading…
Reference in New Issue
Block a user