Support Class Library
A set of tools providing classes and utility
RuntimeException.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include <scl/macros.h>
5 #include <stdexcept>
6 #include <utility>
7 
8 namespace scl{
9  namespace exceptions{
13  class RuntimeException : public Throwable, public std::runtime_error{
14  protected:
19  realConst(char*) _reason = "";
20 
21  public:
27  template <class T>
28  RuntimeException(T&& reason) : _reason{std::forward<T>(reason)}, runtime_error{std::forward<T>(reason)} {
29  }
30 
35  realConst(char*) reason() const override{
36  return this->_reason;
37  }
38 
43  const char* what() const noexcept override{
44  return this->reason();
45  }
46 
51  realConst(char*) type() const noexcept override{
52  return "scl::exceptions::RuntimeException";
53  }
54  };
55  }
56 }
const char *const type() const noexcept override
A string describing the name of the exception class.
const char * what() const noexcept override
Override that uses the user defined reason.
Global namespace of the SCL.
Definition: alias.hpp:3
#define realConst(type)
Definition: macros.h:3
const char *const _reason
The error message that comes with this Exception.
const char *const reason() const override
Retrieve the reason.
Base class of all throwable objects.
Definition: Throwable.h:15
RuntimeException(T &&reason)
Construct an scl::exceptions::Exception from an error message.
Base class for exceptions that could never be checked at compile-time.