ITAException.h 1.66 KB
Newer Older
Jonas Stienen's avatar
Jonas Stienen committed
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
43
44
45
46
/*
* ----------------------------------------------------------------
*
*		ITA core libs
*		(c) Copyright Institute of Technical Acoustics (ITA)
*		RWTH Aachen University, Germany, 2015-2016
*
* ----------------------------------------------------------------
*				    ____  __________  _______
*				   //  / //__   ___/ //  _   |
*				  //  /    //  /    //  /_|  |
*				 //  /    //  /    //  ___   |
*				//__/    //__/    //__/   |__|
*
* ----------------------------------------------------------------
*
*/
// $Id: ITAException.h 3828 2014-11-27 10:43:43Z fwefers $

#ifndef INCLUDE_WATCHER_ITA_EXCEPTION
#define INCLUDE_WATCHER_ITA_EXCEPTION

// ITABase
#include <ITABaseDefinitions.h>

// STL
#include <ostream>
#include <string>

//! Base class for exceptions
class ITA_BASE_API ITAException
{
public:
	//! Error types
	enum
	{
		UNKNOWN = 1,		//!< Unspecified
		OUT_OF_MEMORY,		//!< Out of memory
		INVALID_PARAMETER,	//!< Invalid parameter
		MODAL_EXCEPTION,
		IO_ERROR,
		NOT_IMPLEMENTED,
		FILE_NOT_FOUND,
		PARSE_ERROR,
		SYNTAX_ERROR,
		CONFIG_ERROR,
47
		NETWORK_ERROR,
Jonas Stienen's avatar
Jonas Stienen committed
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
		LAST,
	};

	ITAException( int uiErrorcode = UNKNOWN, std::string sModule = "", std::string sReason = "");
	inline virtual ~ITAException() {};

	std::string ToString() const;

	int iErrorCode;		//!< Error code
	std::string sModule;	//!< Module name
	std::string sReason;	//!< Versatile reason
};

// Helper macros
#define ITA_EXCEPT0( TYPE ) throw ITAException( ITAException::TYPE, __FUNCTION__ );
#define ITA_EXCEPT1( TYPE, REASON ) throw ITAException( ITAException::TYPE, __FUNCTION__, REASON );

//! STL stream output operator
ITA_BASE_API std::ostream& operator<<(std::ostream& os, const ITAException& ex);

#endif