algorithms  2.2.0
Framework-independent algorithms for the EIC
Loading...
Searching...
No Matches
error.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2// Copyright (C) 2022 Wouter Deconinck, Sylvester Joosten
3//
4// A simple exception base class that transports both an error message and error type
5
6#pragma once
7
8#include <exception>
9#include <string>
10
11namespace algorithms {
12
13class Error : public std::exception {
14public:
15 Error(std::string_view msg, std::string_view type = "algorithms::Error")
16 : m_msg{msg}, m_type{type} {}
17
18 virtual const char* what() const noexcept { return m_msg.c_str(); }
19 virtual const char* type() const noexcept { return m_type.c_str(); }
20 virtual ~Error() noexcept {}
21
22private:
23 const std::string m_msg;
24 const std::string m_type;
25};
26
27} // namespace algorithms
28
Error(std::string_view msg, std::string_view type="algorithms::Error")
Definition error.h:15
virtual const char * type() const noexcept
Definition error.h:19
virtual const char * what() const noexcept
Definition error.h:18
virtual ~Error() noexcept
Definition error.h:20