From 7e6341587ba174309989ddebf7cc6a489751b0a8 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Thu, 27 Apr 2023 21:21:19 +0330 Subject: AK+Everywhere: Disallow Error::from_string_view(FooString) That pattern seems to show up a lot in code written by people that aren't intimately familiar with the lifetime model of Error and Strings. This commit makes the compiler detect it and present a more helpful diagnostic than "garbage string at runtime". --- Userland/Libraries/LibGUI/JsonArrayModel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Userland/Libraries/LibGUI') diff --git a/Userland/Libraries/LibGUI/JsonArrayModel.cpp b/Userland/Libraries/LibGUI/JsonArrayModel.cpp index 97733033d0..b5baec6a60 100644 --- a/Userland/Libraries/LibGUI/JsonArrayModel.cpp +++ b/Userland/Libraries/LibGUI/JsonArrayModel.cpp @@ -89,7 +89,7 @@ ErrorOr JsonArrayModel::set(int row, Vector&& fields) VERIFY(fields.size() == m_fields.size()); if ((size_t)row >= m_array.size()) - return Error::from_string_view(TRY(String::formatted("Row out of bounds: {} >= {}", row, m_array.size()))); + return Error::from_string_view("Row out of bounds"sv); JsonObject obj; for (size_t i = 0; i < m_fields.size(); ++i) { @@ -106,7 +106,7 @@ ErrorOr JsonArrayModel::set(int row, Vector&& fields) ErrorOr JsonArrayModel::remove(int row) { if ((size_t)row >= m_array.size()) - return Error::from_string_view(TRY(String::formatted("Row out of bounds: {} >= {}", row, m_array.size()))); + return Error::from_string_view("Row out of bounds"sv); JsonArray new_array; for (size_t i = 0; i < m_array.size(); ++i) -- cgit v1.2.3