aboutsummaryrefslogtreecommitdiff
path: root/Exception.h
blob: 5c84aad81457a0815ec0f2bfa93175a93b37274f (plain)
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
47
48
#pragma once

#include <cstdarg>
#include <exception>

#include "Node.h"

class Exception : public std::exception {
public:
	//! create an exception using printf-syntax
	Exception(const char * fmt, ...);
	virtual ~Exception();
	//! get the formatted string
	virtual const char * what();

protected:
	Exception() = default;
	//! internal variadic argument format handling
	void va_format(va_list args, const char * fmt);
	//! pointer to string returned by \p what()
	char * error = NULL;
};

class ParserException : public Exception {
	using Exception::Exception;

public:
	//! create an exception related to file format parsing
	ParserException(const char * fmt, ...);
};

class CircuitException : public Exception {
	using Exception::Exception;

public:
	//! create an exception related to the Circuit
	CircuitException(const char * fmt, ...);
	Node * node = nullptr;
};

class NodeException : public CircuitException {
	using CircuitException::CircuitException;

public:
	//! create an exception related to a specific node in a Circuit
	NodeException(Node * node, const char * fmt, ...);
};