mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 18:57:35 +00:00
Everywhere: Split Error::from_string_literal and Error::from_string_view
Error::from_string_literal now takes direct char const*s, while Error::from_string_view does what Error::from_string_literal used to do: taking StringViews. This change will remove the need to insert `sv` after error strings when returning string literal errors once StringView(char const*) is removed. No functional changes.
This commit is contained in:
parent
c70f45ff44
commit
e5f09ea170
51 changed files with 282 additions and 261 deletions
|
@ -32,7 +32,7 @@ ErrorOr<void> ProjectBuilder::build(StringView active_file)
|
|||
}
|
||||
|
||||
if (active_file.is_null())
|
||||
return Error::from_string_literal("no active file"sv);
|
||||
return Error::from_string_literal("no active file");
|
||||
|
||||
if (active_file.ends_with(".js")) {
|
||||
TRY(m_terminal->run_command(String::formatted("js -A {}", active_file)));
|
||||
|
@ -58,7 +58,7 @@ ErrorOr<void> ProjectBuilder::run(StringView active_file)
|
|||
}
|
||||
|
||||
if (active_file.is_null())
|
||||
return Error::from_string_literal("no active file"sv);
|
||||
return Error::from_string_literal("no active file");
|
||||
|
||||
if (active_file.ends_with(".js")) {
|
||||
TRY(m_terminal->run_command(String::formatted("js {}", active_file)));
|
||||
|
@ -89,7 +89,7 @@ ErrorOr<void> ProjectBuilder::update_active_file(StringView active_file)
|
|||
auto cmake_file = find_cmake_file_for(active_file);
|
||||
if (!cmake_file.has_value()) {
|
||||
warnln("did not find cmake file for: {}", active_file);
|
||||
return Error::from_string_literal("did not find cmake file"sv);
|
||||
return Error::from_string_literal("did not find cmake file");
|
||||
}
|
||||
|
||||
if (m_serenity_component_cmake_file == cmake_file.value())
|
||||
|
@ -116,7 +116,7 @@ ErrorOr<String> ProjectBuilder::component_name(StringView cmake_file_path)
|
|||
static Regex<ECMA262> const component_name(R"~~~(serenity_component\([\s]*(\w+)[\s\S]*\))~~~");
|
||||
RegexResult result;
|
||||
if (!component_name.search(StringView { content }, result))
|
||||
return Error::from_string_literal("component not found"sv);
|
||||
return Error::from_string_literal("component not found");
|
||||
|
||||
return String { result.capture_group_matches.at(0).at(0).view.string_view() };
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ ErrorOr<void> ProjectBuilder::verify_cmake_is_installed()
|
|||
auto res = Core::command("cmake --version", {});
|
||||
if (!res.is_error() && res.value().exit_code == 0)
|
||||
return {};
|
||||
return Error::from_string_literal("CMake port is not installed"sv);
|
||||
return Error::from_string_literal("CMake port is not installed");
|
||||
}
|
||||
|
||||
ErrorOr<void> ProjectBuilder::verify_make_is_installed()
|
||||
|
@ -263,7 +263,7 @@ ErrorOr<void> ProjectBuilder::verify_make_is_installed()
|
|||
auto res = Core::command("make --version", {});
|
||||
if (!res.is_error() && res.value().exit_code == 0)
|
||||
return {};
|
||||
return Error::from_string_literal("Make port is not installed"sv);
|
||||
return Error::from_string_literal("Make port is not installed");
|
||||
}
|
||||
|
||||
String ProjectBuilder::build_directory() const
|
||||
|
|
|
@ -49,7 +49,7 @@ ErrorOr<void> TerminalWrapper::run_command(String const& command, Optional<Strin
|
|||
|
||||
VERIFY(m_child_exit_status.has_value());
|
||||
if (m_child_exit_status.value() != 0)
|
||||
return Error::from_string_literal(failure_message.value_or("Command execution failed"sv));
|
||||
return Error::from_string_view(failure_message.value_or("Command execution failed"sv));
|
||||
}
|
||||
|
||||
return {};
|
||||
|
|
|
@ -240,7 +240,7 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
|
|||
|
||||
auto json = JsonValue::from_string(file->read_all());
|
||||
if (json.is_error() || !json.value().is_object())
|
||||
return Error::from_string_literal("Invalid perfcore format (not a JSON object)"sv);
|
||||
return Error::from_string_literal("Invalid perfcore format (not a JSON object)");
|
||||
|
||||
auto const& object = json.value().as_object();
|
||||
|
||||
|
@ -255,7 +255,7 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
|
|||
|
||||
auto const* strings_value = object.get_ptr("strings"sv);
|
||||
if (!strings_value || !strings_value->is_array())
|
||||
return Error::from_string_literal("Malformed profile (strings is not an array)"sv);
|
||||
return Error::from_string_literal("Malformed profile (strings is not an array)");
|
||||
|
||||
HashMap<FlatPtr, String> profile_strings;
|
||||
for (FlatPtr string_id = 0; string_id < strings_value->as_array().size(); ++string_id) {
|
||||
|
@ -265,7 +265,7 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
|
|||
|
||||
auto const* events_value = object.get_ptr("events");
|
||||
if (!events_value || !events_value->is_array())
|
||||
return Error::from_string_literal("Malformed profile (events is not an array)"sv);
|
||||
return Error::from_string_literal("Malformed profile (events is not an array)");
|
||||
|
||||
auto const& perf_events = events_value->as_array();
|
||||
|
||||
|
@ -446,7 +446,7 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
|
|||
}
|
||||
|
||||
if (events.is_empty())
|
||||
return Error::from_string_literal("No events captured (targeted process was never on CPU)"sv);
|
||||
return Error::from_string_literal("No events captured (targeted process was never on CPU)");
|
||||
|
||||
quick_sort(all_processes, [](auto& a, auto& b) {
|
||||
if (a.pid == b.pid)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue