Skip to content

Commit e7acfdb

Browse files
committed
Remove catch-all handler from make_canonicalize_path_error_handlers
A user of make_canonicalize_path_error_handlers might want to have its own catch-all handler. Remove the catch-all handler from make_canonicalize_path_error_handlers to give callers more flexibility.
1 parent 00f7d9e commit e7acfdb

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/file-canonical.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,11 @@ sloppy_result<canonical_path_result> canonicalize_path_sloppy(
714714
make_canonicalize_path_error_handlers([](std::string &&message) {
715715
return sloppy_result<canonical_path_result>::failure(
716716
std::move(message));
717-
}));
717+
}),
718+
[]() {
719+
QLJS_ASSERT(false);
720+
return sloppy_result<canonical_path_result>::failure("unknown error");
721+
});
718722
}
719723

720724
sloppy_result<canonical_path_result> canonicalize_path_sloppy(

src/quick-lint-js/file-canonical.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,6 @@ auto make_canonicalize_path_error_handlers(const Func &handle_error) {
165165
QLJS_ASSERT(false); // One of the above handlers should have handled
166166
// the error already.
167167
return handle_error("failed to canonicalize path"s);
168-
},
169-
[handle_error]() {
170-
// TODO(strager): Get rid of this handler.
171-
QLJS_ASSERT(false); // One of the above handlers should have handled
172-
// the error already.
173-
return handle_error("failed to canonicalize path"s);
174168
});
175169
}
176170
}

test/test-file-canonical.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,11 @@ boost::leaf::result<void> canonicalize_expecting_failure(const Path& path) {
8383
}
8484

8585
auto fail_test_error_handlers() {
86-
return make_canonicalize_path_error_handlers([](const std::string& message) {
87-
ADD_FAILURE() << "error: " << message;
88-
});
86+
return std::tuple(
87+
make_canonicalize_path_error_handlers([](const std::string& message) {
88+
ADD_FAILURE() << "error: " << message;
89+
}),
90+
[]() { ADD_FAILURE() << "unknown error"; });
8991
}
9092

9193
bool process_ignores_filesystem_permissions() noexcept {

0 commit comments

Comments
 (0)