srctree

Robin Linden parent f9d6b696 4123e2c1
protocol: Add an error for redirect loops

inlinesplit
browser/gui/app.cpp added: 13, removed: 4, total 9
@@ -380,6 +380,11 @@ void App::on_navigation_failure(protocol::Error err) {
spdlog::error(nav_widget_extra_info_);
break;
}
case protocol::Error::RedirectLimit: {
nav_widget_extra_info_ = fmt::format("Redirect limit hit while loading '{}'", url_buf_);
spdlog::error(nav_widget_extra_info_);
break;
}
case protocol::Error::Ok:
default:
spdlog::error("This should never happen: {}", static_cast<int>(err));
 
protocol/response.cpp added: 13, removed: 4, total 9
@@ -23,6 +23,8 @@ std::string_view to_string(Error e) {
return "Unhandled";
case Error::InvalidResponse:
return "InvalidResponse";
case Error::RedirectLimit:
return "RedirectLimit";
}
return "Unknown";
}
 
protocol/response.h added: 13, removed: 4, total 9
@@ -21,6 +21,7 @@ enum class Error {
Unresolved,
Unhandled,
InvalidResponse,
RedirectLimit,
};
 
std::string_view to_string(Error);
 
protocol/response_test.cpp added: 13, removed: 4, total 9
@@ -43,6 +43,7 @@ int main() {
expect_eq(to_string(Error::Unresolved), "Unresolved"sv);
expect_eq(to_string(Error::Unhandled), "Unhandled"sv);
expect_eq(to_string(Error::InvalidResponse), "InvalidResponse"sv);
expect_eq(to_string(Error::RedirectLimit), "RedirectLimit"sv);
expect_eq(to_string(static_cast<Error>(std::underlying_type_t<Error>{20})), "Unknown"sv);
});