CellularAutomata
Loading...
Searching...
No Matches
exceptions.hpp
1#pragma once
2
3#include <stdexcept>
4#include <string>
5
6
7#define DEFINE_EXCEPTION_CLASS(name) \
8class name : public std::exception { \
9 std::string msg; \
10 public: \
11 \
12 explicit name() : msg(#name) { } \
13 \
14 explicit name(std::string message) : msg(#name) { msg = msg + " - " + message; } \
15 \
16 explicit name(const char* message) : msg(#name) { msg = msg + " - " + std::string(message); } \
17 \
18 const char* what() const noexcept override { return msg.c_str(); } \
19 }
20
21namespace CellularAutomata
22{
26 namespace exception
27 {
31 DEFINE_EXCEPTION_CLASS(DeviceNotAvailable);
32
36 DEFINE_EXCEPTION_CLASS(DevicesUnequal);
37
41 DEFINE_EXCEPTION_CLASS(ShapesUnequal);
42
46 DEFINE_EXCEPTION_CLASS(OutOfBounds);
47
53 DEFINE_EXCEPTION_CLASS(CudaRuntime);
54 }
55}
56
57#undef DEFINE_EXCEPTION_CLASS
A CUDA runtime error occurred.
Definition exceptions.hpp:53
Requested device not available.
Definition exceptions.hpp:31
Objects are on different devices.
Definition exceptions.hpp:36
Accessed a value outside the bounds of matrix.
Definition exceptions.hpp:46
Shape of two matrices are not equal.
Definition exceptions.hpp:41
Main namespace.
Definition common.hpp:33