FileManager: Use VERIFY() instead of if checks with VERIFY_NOT_REACHED

Besides micro simplifying the code, this will also show the failed
condition in the console, instead of vague 'ASSERTION FAILED: false'.
This commit is contained in:
Karol Kosek 2022-04-23 23:05:06 +02:00 committed by Linus Groh
parent 6463bc7eb3
commit ff6df9f27e

View file

@ -131,8 +131,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
void do_copy(Vector<String> const& selected_file_paths, FileOperation file_operation)
{
if (selected_file_paths.is_empty())
VERIFY_NOT_REACHED();
VERIFY(!selected_file_paths.is_empty());
StringBuilder copy_text;
if (file_operation == FileOperation::Move) {
@ -343,9 +342,7 @@ ErrorOr<int> run_in_desktop_mode()
auto cut_action = GUI::CommonActions::make_cut_action(
[&](auto&) {
auto paths = directory_view->selected_file_paths();
if (paths.is_empty())
VERIFY_NOT_REACHED();
VERIFY(!paths.is_empty());
do_copy(paths, FileOperation::Move);
},
@ -355,9 +352,7 @@ ErrorOr<int> run_in_desktop_mode()
auto copy_action = GUI::CommonActions::make_copy_action(
[&](auto&) {
auto paths = directory_view->selected_file_paths();
if (paths.is_empty())
VERIFY_NOT_REACHED();
VERIFY(!paths.is_empty());
do_copy(paths, FileOperation::Copy);
},
@ -727,12 +722,9 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
auto cut_action = GUI::CommonActions::make_cut_action(
[&](auto&) {
auto paths = directory_view->selected_file_paths();
if (paths.is_empty())
paths = tree_view_selected_file_paths();
if (paths.is_empty())
VERIFY_NOT_REACHED();
VERIFY(!paths.is_empty());
do_copy(paths, FileOperation::Move);
refresh_tree_view();
@ -743,12 +735,9 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
auto copy_action = GUI::CommonActions::make_copy_action(
[&](auto&) {
auto paths = directory_view->selected_file_paths();
if (paths.is_empty())
paths = tree_view_selected_file_paths();
if (paths.is_empty())
VERIFY_NOT_REACHED();
VERIFY(!paths.is_empty());
do_copy(paths, FileOperation::Copy);
refresh_tree_view();