diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2023-06-11 13:17:56 +0200 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2023-06-11 13:17:56 +0200 |
commit | 8228426823ce6f305e2d2eb687aeb78c20109259 (patch) | |
tree | a78abf9eff9a40c67f90b31eace1e4d39d6e5e86 /src/core/error.cpp | |
parent | 73fac05aa07a0dd16f7061baddd4b934c7855fed (diff) |
core,c++: Fixed an error_registry bootstrap infinite recursion bug
Diffstat (limited to 'src/core/error.cpp')
-rw-r--r-- | src/core/error.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/core/error.cpp b/src/core/error.cpp index ef8dc57..9520972 100644 --- a/src/core/error.cpp +++ b/src/core/error.cpp @@ -76,14 +76,31 @@ error no_error(){ } namespace impl { +error_registry::error_registry(): + infos_{ + { + err::no_error::description, + err::no_error::is_critical + }, + { + err::not_found::description, + err::not_found::is_critical + }, + { + err::out_of_memory::description, + err::out_of_memory::is_critical + } + } +{} + error_or<error::code> error_registry::search_id(const std::string_view& desc)const{ /** * Search the index in the vector */ size_t i{}; - size_t info_max_size = std::min<std::size_t>(infos.size(), std::numeric_limits<error::code>::max()); + size_t info_max_size = std::min<std::size_t>(infos_.size(), std::numeric_limits<error::code>::max()); for(i = 0; i < info_max_size; ++i){ - if(infos.at(i).description == desc){ + if(infos_.at(i).description == desc){ break; } } @@ -105,11 +122,11 @@ error_or<error::code> error_registry::search_or_register_id(const std::string_vi auto& err = err_or_id.get_error(); if(err.is_type<err::not_found>()){ - size_t new_index = infos.size(); + size_t new_index = infos_.size(); if(new_index == std::numeric_limits<error::code>::max()){ return make_error<err::out_of_memory>("Error registry ids are exhausted"); } - infos.emplace_back(error_info{desc, is_critical}); + infos_.emplace_back(error_info{desc, is_critical}); return static_cast<error::code>(new_index); } |