forked from scummvm/scummvm-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tool_exception.h
57 lines (49 loc) · 1.8 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
57
/* ScummVM Tools
* Copyright (C) 2002-2009 The ScummVM project
*
* 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 2
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#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