Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:34:29

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2022 Wouter Deconinck, Sylvester Joosten
0003 //
0004 // A simple exception base class that transports both an error message and error type
0005 
0006 #pragma once
0007 
0008 #include <exception>
0009 #include <string>
0010 
0011 namespace algorithms {
0012 
0013 class Error : public std::exception {
0014 public:
0015   Error(std::string_view msg, std::string_view type = "algorithms::Error")
0016       : m_msg{msg}, m_type{type} {}
0017 
0018   virtual const char* what() const noexcept { return m_msg.c_str(); }
0019   virtual const char* type() const noexcept { return m_type.c_str(); }
0020   virtual ~Error() noexcept {}
0021 
0022 private:
0023   const std::string m_msg;
0024   const std::string m_type;
0025 };
0026 
0027 } // namespace algorithms
0028