forked from scummvm/scummvm-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tool_exception.h
56 lines (50 loc) · 1.85 KB
/
tool_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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* ScummVM Tools
*
* ScummVM Tools is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef TOOL_EXCEPTION_H
#define TOOL_EXCEPTION_H
#include <string>
#include <stdexcept>
/**
* Throw an exception of this type (or subtype of it), if the tool fails fatally.
* This type is intended for general errors
*/
class ToolException : public std::runtime_error {
public:
/**
* Construct an exception, with an appropriate error message
* A return value for the tool should be supplied if none is appropriate
* @todo If the tools are even more C++ized, the tool should decide retcode itself, not by exception
*
* @param error The error message
* @param retcode The return value of the process
*/
ToolException(std::string error, int retcode = -1) : std::runtime_error(error), _retcode(retcode) {}
int _retcode;
};
/**
* Something unexpected happened while reading / writing to a file
* Usually premature end, or that it could not be opened (write / read protected)
*/
class AbortException : public ToolException {
public:
AbortException() : ToolException("Operation was aborted", -2) {}
};
#endif