diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-08-27 16:38:47 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-08-27 16:38:47 +0200 |
| commit | 346a7af8b1774ab085114aa3573fbf400683552d (patch) | |
| tree | 2516483cb165e18d6bccbd8fb5ca7758dd802845 | |
| parent | 7ea0c074329dd55de43ea3b07ff545228cb0d729 (diff) | |
feat: core: introduce `error_handler` container.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
| -rw-r--r-- | dev/lib/core/error_handler.hpp | 35 | ||||
| -rw-r--r-- | dev/lib/net/modem.hpp | 4 | ||||
| -rwxr-xr-x | tools/hpptest.py | 7 |
3 files changed, 41 insertions, 5 deletions
diff --git a/dev/lib/core/error_handler.hpp b/dev/lib/core/error_handler.hpp new file mode 100644 index 0000000..0331f81 --- /dev/null +++ b/dev/lib/core/error_handler.hpp @@ -0,0 +1,35 @@ +/* +* File: fix/parser.hpp +* Purpose: Error handler container. +* Author: Amlal El Mahrouss (amlal@nekernel.org) +* Copyright 2025, Amlal El Mahrouss. +*/ + +#ifndef _OCL_ERROR_HANDLER_HPP +#define _OCL_ERROR_HANDLER_HPP + +#include <lib/core/includes.hpp> +#include <stdexcept> + +namespace ocl +{ + struct basic_error_handler; + + struct basic_error_handler + { + explicit basic_error_handler() = default; + virtual ~basic_error_handler() = default; + + basic_error_handler& operator=(const basic_error_handler&) = delete; + basic_error_handler(const basic_error_handler&) = delete; + + void operator()(const std::basic_string<char>& msg) + { + throw std::runtime_error(msg); + } + }; + + using standard_error_handler = basic_error_handler; +} // namespace ocl + +#endif // ifndef _OCL_ERROR_HANDLER_HPP diff --git a/dev/lib/net/modem.hpp b/dev/lib/net/modem.hpp index bcf2a79..074f182 100644 --- a/dev/lib/net/modem.hpp +++ b/dev/lib/net/modem.hpp @@ -35,7 +35,7 @@ namespace ocl::net const bool& bad{bad_}; explicit basic_modem() = default; - + virtual ~basic_modem() { this->destroy(); @@ -101,7 +101,7 @@ namespace ocl::net auto ret = ::send(fd_, out.data(), out.size(), 0); bad_ = !(ret >= 0L); - + return ret >= 0L; } diff --git a/tools/hpptest.py b/tools/hpptest.py index 744ffde..dbed143 100755 --- a/tools/hpptest.py +++ b/tools/hpptest.py @@ -4,7 +4,8 @@ import sys, os if __name__ == '__main__': - if len(sys.argv) == 2: - os.system(f"clang++ -std=c++20 -DOCL_HPPTEST '-DOCL_HPPTEST_ASSERT(x)=static_assert(x, #x)' {sys.argv[1]}") - print("[TEST] HEADER COMPILATION PASSES") + if len(sys.argv) == 3: + ret = os.system(f"clang++ -I./dev/ -I{sys.argv[2]} -std=c++20 -DOCL_HPPTEST '-DOCL_HPPTEST_ASSERT(x)=static_assert(x, #x)' {sys.argv[1]}") + if ret == 0: + print("[TEST] HEADER COMPILATION PASSES") |
