gz-cpp-util 1.3
A c++20 library containing various utilities
exceptions.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <exception>
4#include <string>
5
6namespace gz {
7
11 class Exception : public std::exception {
12 public:
13 Exception(const std::string& what) : whatStr(what) {};
14 Exception(const std::string& what, const std::string& functionName) : whatStr(functionName + ": " + what) {};
15 virtual const char* what() const noexcept override { return whatStr.c_str(); };
16 private:
17 std::string whatStr;
18 };
19
23 class FileIOError : public Exception {
24 public:
25 FileIOError(const std::string& what) : Exception(what) {};
26 FileIOError(const std::string& what, const std::string& functionName)
27 : Exception(what, functionName) {};
28 };
29
33 class InvalidArgument : public Exception {
34 public:
35 InvalidArgument(const std::string& what) : Exception(what) {};
36 InvalidArgument(const std::string& what, const std::string& functionName)
37 : Exception(what, functionName) {};
38 };
39
43 class InvalidType : public Exception {
44 public:
45 InvalidType(const std::string& what) : Exception(what) {};
46 InvalidType(const std::string& what, const std::string& functionName)
47 : Exception(what, functionName) {};
48 };
49
50
51}
52
The parent for all other exceptions.
Definition: exceptions.hpp:11
Any error that occurs during file io.
Definition: exceptions.hpp:23
Any error that implies an invalid argument was passed to a function.
Definition: exceptions.hpp:33
Any error where a wrong type was used.
Definition: exceptions.hpp:43