From 346a7af8b1774ab085114aa3573fbf400683552d Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Wed, 27 Aug 2025 16:38:47 +0200 Subject: feat: core: introduce `error_handler` container. Signed-off-by: Amlal El Mahrouss --- dev/lib/core/error_handler.hpp | 35 +++++++++++++++++++++++++++++++++++ dev/lib/net/modem.hpp | 4 ++-- 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 dev/lib/core/error_handler.hpp (limited to 'dev') 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 +#include + +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& 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; } -- cgit v1.2.3