-
Notifications
You must be signed in to change notification settings - Fork 0
/
Exception.h
42 lines (34 loc) · 865 Bytes
/
Exception.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* Exception.h
*
* Created on: Jul 17, 2013
* Author: marcel
*/
#ifndef HDF5_EXCEPTION_H_
#define HDF5_EXCEPTION_H_
#include <exception>
#include <string>
#include <sstream>
namespace hdf5
{
class Exception: public std::exception
{
public:
Exception() throw(): msg(""), id(0) {};
Exception(const std::string& msg, unsigned int id = 0) throw() : msg(msg), id(id) {};
Exception(const std::stringstream& msg, unsigned int id = 0) throw() : msg(msg.str()), id(id) {};
virtual ~Exception() throw() {};
Exception& operator=(const Exception& original) throw() {
if (this != &original) {
msg = original.msg;
id = original.id;
}
return *this;
}
const char* what() const throw() { return msg.c_str(); }
private:
std::string msg;
unsigned int id;
};
} /* namespace hdf5 */
#endif /* EXCEPTION_H_ */