ScummVM API documentation
error.h
1
2/* ScummVM - Graphic Adventure Engine
3 *
4 * ScummVM is the legal property of its developers, whose names
5 * are too numerous to list here. Please refer to the COPYRIGHT
6 * file distributed with this source distribution.
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#ifndef BAGEL_BOFLIB_ERROR_H
24#define BAGEL_BOFLIB_ERROR_H
25
26#include "common/str.h"
27
28namespace Bagel {
29
33enum ErrorCode {
34 ERR_NONE = 0, /* no error */
35 ERR_MEMORY = 1, /* not enough memory */
36 ERR_FOPEN = 2, /* error opening a file */
37 ERR_FREAD = 4, /* error reading a file */
38 ERR_FWRITE = 5, /* error writing a file */
39 ERR_FSEEK = 6, /* error seeking a file */
40 ERR_FFIND = 8, /* could not find file */
41 ERR_FTYPE = 9, /* invalid file type */
42 ERR_UNKNOWN = 12, /* unknown error */
43 ERR_CRC = 13, /* file or data failed CRC check */
44};
45
46#define ERROR_CODE ErrorCode
47#define MAX_ERRORS 3
48
49extern const char *const g_errList[];
50#define errList g_errList
51
52class CBofError {
53protected:
54 static int _count;
55 ErrorCode _errCode;
56
57 virtual void bofMessageBox(const Common::String &content, const Common::String &title) {
58 }
59
60public:
61 CBofError();
62 virtual ~CBofError() {
63 }
64
73 void reportError(ErrorCode errCode, const char *format, ...);
74
81 static void fatalError(ErrorCode errCode, const char *format, ...);
82
83 bool errorOccurred() const {
84 return _errCode != ERR_NONE;
85 }
86 ErrorCode getErrorCode() const {
87 return _errCode;
88 }
89 void clearError() {
90 _errCode = ERR_NONE;
91 }
92
93 static void initialize();
94
95 static int getErrorCount() {
96 return _count;
97 }
98
99};
100
101} // namespace Bagel
102
103#endif
Definition: error.h:52
static void fatalError(ErrorCode errCode, const char *format,...)
void reportError(ErrorCode errCode, const char *format,...)
Definition: str.h:59
ErrorCode
Definition: error.h:47