SPH
Exceptions.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "common/Globals.h"
4 #include <exception>
5 #include <string>
6 
8 
10 class Exception : public std::exception {
11 private:
12  std::string message;
13 
14 public:
15  explicit Exception(const std::string& message)
16  : message(message) {}
17 
18  virtual const char* what() const noexcept {
19  return message.c_str();
20  }
21 };
22 
24 class InvalidSetup : public Exception {
25 public:
26  explicit InvalidSetup(const std::string& message)
27  : Exception(message) {}
28 };
29 
31 class IoError : public Exception {
32 public:
33  explicit IoError(const std::string& message)
34  : Exception(message) {}
35 };
36 
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
Global parameters of the code.
#define NAMESPACE_SPH_END
Definition: Object.h:12
Generic exception.
Definition: Exceptions.h:10
virtual const char * what() const noexcept
Definition: Exceptions.h:18
Exception(const std::string &message)
Definition: Exceptions.h:15
Thrown when components of the run are mutually incompatible.
Definition: Exceptions.h:24
InvalidSetup(const std::string &message)
Definition: Exceptions.h:26
Exception thrown when file cannot be read, it has invalid format, etc.
Definition: Exceptions.h:31
IoError(const std::string &message)
Definition: Exceptions.h:33