From 0824a76b4f7294a74f4728084ca13070a4c8e7da Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Sat, 29 Aug 2026 10:53:39 +0200 Subject: chore: normalize panic messages --- libs/kstd/kstd/bits/basic_string.hpp | 30 +++++++++++------------ libs/kstd/kstd/bits/format/context.hpp | 2 +- libs/kstd/kstd/bits/format/error.hpp | 2 +- libs/kstd/kstd/bits/format/formatter/ordering.hpp | 6 ++--- libs/kstd/kstd/bits/mutex/mutex.cpp | 2 +- libs/kstd/kstd/bits/observer_ptr.hpp | 2 +- libs/kstd/kstd/flat_map.hpp | 8 +++--- libs/kstd/kstd/libc/stdlib.cpp | 2 +- libs/kstd/kstd/vector.hpp | 8 +++--- 9 files changed, 31 insertions(+), 31 deletions(-) (limited to 'libs/kstd') diff --git a/libs/kstd/kstd/bits/basic_string.hpp b/libs/kstd/kstd/bits/basic_string.hpp index a718bccc..1f8b60af 100644 --- a/libs/kstd/kstd/bits/basic_string.hpp +++ b/libs/kstd/kstd/bits/basic_string.hpp @@ -137,7 +137,7 @@ namespace kstd { if (!source && count) { - os::panic("Tried to construct string from null pointer!"); + os::panic("[KSTD:STR] Tried to construct string from null pointer!"); } if (count > capacity()) @@ -333,7 +333,7 @@ namespace kstd { if (string == nullptr) { - os::panic("Tried to construct string from null pointer!"); + os::panic("[KSTD:STR] Tried to construct string from null pointer!"); } auto incoming_length = traits_type::length(string); @@ -454,7 +454,7 @@ namespace kstd { if (position >= size()) { - os::panic("Invalid index in string element access"); + os::panic("[KSTD:STR] Invalid index in string element access"); } return m_data[position]; @@ -468,7 +468,7 @@ namespace kstd { if (position >= size()) { - os::panic("Invalid index in string element access"); + os::panic("[KSTD:STR] Invalid index in string element access"); } return m_data[position]; @@ -673,7 +673,7 @@ namespace kstd { if (new_capacity > max_size()) { - os::panic("Tried to allocate more memory than possible"); + os::panic("[KSTD:STR] Tried to allocate more memory than possible"); } if (new_capacity <= capacity()) @@ -733,7 +733,7 @@ namespace kstd { if (index > size()) { - os::panic("Index out of bounds while inserting into string"); + os::panic("[KSTD:STR] Index out of bounds while inserting into string"); } if (count == 0uz) @@ -770,7 +770,7 @@ namespace kstd { if (string == nullptr) { - os::panic("Tried to insert nullptr string"); + os::panic("[KSTD:STR] Tried to insert nullptr string"); } return do_insert(index, std::basic_string_view{string}); @@ -788,7 +788,7 @@ namespace kstd { if (range == nullptr) { - os::panic("Tried to insert nullptr range"); + os::panic("[KSTD:STR] Tried to insert nullptr range"); } return do_insert(index, std::basic_string_view{range, length}); @@ -880,7 +880,7 @@ namespace kstd { if (string == nullptr) { - os::panic("Attempted to append nullptr string"); + os::panic("[KSTD:STR] Attempted to append nullptr string"); } if (count == 0) @@ -1312,7 +1312,7 @@ namespace kstd { if (rhs == nullptr) { - os::panic("Tried to compare a string with nullptr"); + os::panic("[KSTD:STR] Tried to compare a string with nullptr"); } return lhs == std::basic_string_view{rhs}; @@ -1322,7 +1322,7 @@ namespace kstd { if (rhs == nullptr) { - os::panic("Tried to compare a string with nullptr"); + os::panic("[KSTD:STR] Tried to compare a string with nullptr"); } return std::basic_string_view{lhs} == rhs; @@ -1349,7 +1349,7 @@ namespace kstd { if (rhs == nullptr) { - os::panic("Tried to compare a string with nullptr"); + os::panic("[KSTD:STR] Tried to compare a string with nullptr"); } return lhs <=> std::basic_string_view{rhs}; @@ -1359,7 +1359,7 @@ namespace kstd { if (rhs == nullptr) { - os::panic("Tried to compare a string with nullptr"); + os::panic("[KSTD:STR] Tried to compare a string with nullptr"); } return std::basic_string_view{lhs} <=> rhs; @@ -1381,7 +1381,7 @@ namespace kstd { if (count > max_size()) { - os::panic("Tried to allocate more memory than possible"); + os::panic("[KSTD:STR] Tried to allocate more memory than possible"); } auto to_allocate = (exact ? count : std::min(std::max(count, 2 * capacity()), max_size())) + 1; @@ -1397,7 +1397,7 @@ namespace kstd { if (index > size()) { - os::panic("Index out of bounds while inserting into string"); + os::panic("[KSTD:STR] Index out of bounds while inserting into string"); } if (view.size() == 0uz) diff --git a/libs/kstd/kstd/bits/format/context.hpp b/libs/kstd/kstd/bits/format/context.hpp index d5f2f4d9..69766592 100644 --- a/libs/kstd/kstd/bits/format/context.hpp +++ b/libs/kstd/kstd/bits/format/context.hpp @@ -41,7 +41,7 @@ namespace kstd { if (id >= args.size()) { - kstd::os::panic("[kstd:format] argument index out of range!"); + kstd::os::panic("[KSTD:FMT] argument index out of range!"); } return args[id]; } diff --git a/libs/kstd/kstd/bits/format/error.hpp b/libs/kstd/kstd/bits/format/error.hpp index c0cb53d7..30cb7523 100644 --- a/libs/kstd/kstd/bits/format/error.hpp +++ b/libs/kstd/kstd/bits/format/error.hpp @@ -15,7 +15,7 @@ namespace kstd::bits::format } else { - kstd::os::panic("Error while formatting a string."); + kstd::os::panic("[KSTD:FMT] Error while formatting a string."); } } diff --git a/libs/kstd/kstd/bits/format/formatter/ordering.hpp b/libs/kstd/kstd/bits/format/formatter/ordering.hpp index 78322262..73d2cac6 100644 --- a/libs/kstd/kstd/bits/format/formatter/ordering.hpp +++ b/libs/kstd/kstd/bits/format/formatter/ordering.hpp @@ -40,7 +40,7 @@ namespace kstd { return context.push(specifiers.alternative_form ? "<" : "less"); } - kstd::os::panic("[kstd:format] Invalid strong ordering value!"); + kstd::os::panic("[KSTD:FMT] Invalid strong ordering value!"); } }; @@ -69,7 +69,7 @@ namespace kstd { return context.push(specifiers.alternative_form ? "<" : "less"); } - kstd::os::panic("[kstd:format] Invalid weak ordering value!"); + kstd::os::panic("[KSTD:FMT] Invalid weak ordering value!"); } }; @@ -102,7 +102,7 @@ namespace kstd { return context.push(specifiers.alternative_form ? "<=>" : "unordered"); } - kstd::os::panic("[kstd:format] Invalid partial ordering value!"); + kstd::os::panic("[KSTD:FMT] Invalid partial ordering value!"); } }; diff --git a/libs/kstd/kstd/bits/mutex/mutex.cpp b/libs/kstd/kstd/bits/mutex/mutex.cpp index f1f43141..6dabb5dd 100644 --- a/libs/kstd/kstd/bits/mutex/mutex.cpp +++ b/libs/kstd/kstd/bits/mutex/mutex.cpp @@ -13,7 +13,7 @@ namespace kstd { if (m_locked.test(std::memory_order_relaxed)) { - os::panic("[KSTD] Tried to destroy a locked mutex."); + os::panic("[KSTD:THR] Tried to destroy a locked mutex."); } } diff --git a/libs/kstd/kstd/bits/observer_ptr.hpp b/libs/kstd/kstd/bits/observer_ptr.hpp index e63e5d77..260d9d33 100644 --- a/libs/kstd/kstd/bits/observer_ptr.hpp +++ b/libs/kstd/kstd/bits/observer_ptr.hpp @@ -130,7 +130,7 @@ namespace kstd { if (m_ptr == nullptr) { - os::panic("[kstd:observer_ptr] Dereferencing a null observer pointer"); + os::panic("[KSTD:MEM] Dereferencing a null observer pointer"); } } diff --git a/libs/kstd/kstd/flat_map.hpp b/libs/kstd/kstd/flat_map.hpp index e140f7dd..c9a33b4a 100644 --- a/libs/kstd/kstd/flat_map.hpp +++ b/libs/kstd/kstd/flat_map.hpp @@ -112,7 +112,7 @@ namespace kstd { if (m_index >= m_containers->keys.size()) { - os::panic("[kstd::flat_map] Iterator out of range"); + os::panic("[KSTD:FLM] Iterator out of range"); } return {m_containers->keys[m_index], m_containers->values[m_index]}; } @@ -199,7 +199,7 @@ namespace kstd { if (it.m_index >= it.m_containers->keys.size()) { - os::panic("[kstd::flat_map] Iterator out of range"); + os::panic("[KSTD:FLM] Iterator out of range"); } return rvalue_reference{static_cast(it.m_containers->keys[it.m_index]), @@ -470,7 +470,7 @@ namespace kstd { return found->second; } - os::panic("[kstd::flat_map] Key not found"); + os::panic("[KSTD:FLM] Key not found"); } //! Get a reference to the mapped value associated with the given key. @@ -487,7 +487,7 @@ namespace kstd { return found->second; } - os::panic("[kstd::flat_map] Key not found"); + os::panic("[KSTD:FLM] Key not found"); } //! Get a reference to the mapped value associated with the given key, or insert a default one if none exists. diff --git a/libs/kstd/kstd/libc/stdlib.cpp b/libs/kstd/kstd/libc/stdlib.cpp index 7ed051fa..098bcd25 100644 --- a/libs/kstd/kstd/libc/stdlib.cpp +++ b/libs/kstd/kstd/libc/stdlib.cpp @@ -12,7 +12,7 @@ namespace kstd::libc [[noreturn, gnu::weak]] auto free(void *) -> void { - kstd::os::panic("Tried to call free."); + kstd::os::panic("[KSTD:MEM] Tried to call free."); } } diff --git a/libs/kstd/kstd/vector.hpp b/libs/kstd/kstd/vector.hpp index 71c380fc..5a56381b 100644 --- a/libs/kstd/kstd/vector.hpp +++ b/libs/kstd/kstd/vector.hpp @@ -551,7 +551,7 @@ namespace kstd if (new_capacity > max_size()) { - kstd::os::panic("[kstd:vector] Tried to reserve more space than theoretically possible."); + kstd::os::panic("[KSTD:VEC] Tried to reserve more space than theoretically possible."); } reallocate_exactly(new_capacity); @@ -580,7 +580,7 @@ namespace kstd if (new_size > max_size()) { - kstd::os::panic("[kstd:vector] Tried to resize more space than theoretically possible."); + kstd::os::panic("[KSTD:VEC] Tried to resize more space than theoretically possible."); } if (new_size > capacity()) @@ -744,7 +744,7 @@ namespace kstd { if (position == end()) { - os::panic("[kstd:vector] Attempted to erase end()!"); + os::panic("[KSTD:VEC] Attempted to erase end()!"); } auto prefix_size = std::ranges::distance(cbegin(), position); @@ -959,7 +959,7 @@ namespace kstd { if (index >= m_size) { - os::panic("[kstd:vector] Attempted to read element at invalid index"); + os::panic("[KSTD:VEC] Attempted to read element at invalid index"); } } -- cgit v1.2.3