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 
28 namespace Bagel {
29 
33 enum 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 MAX_ERRORS 3
47 
48 extern const char *const g_errList[];
49 
50 class CBofError {
51 protected:
52  static int _count;
53  ErrorCode _errCode;
54 
55  virtual void bofMessageBox(const Common::String &content, const Common::String &title) {}
56 
57 public:
58  CBofError();
59  virtual ~CBofError() {}
60 
69  void reportError(ErrorCode errCode, const char *format, ...);
70 
77  static void fatalError(ErrorCode errCode, const char *format, ...);
78 
79  bool errorOccurred() const {
80  return _errCode != ERR_NONE;
81  }
82  ErrorCode getErrorCode() const {
83  return _errCode;
84  }
85  void clearError() {
86  _errCode = ERR_NONE;
87  }
88 
89  static void initialize();
90 
91  static int getErrorCount() {
92  return _count;
93  }
94 
95 };
96 
97 } // namespace Bagel
98 
99 #endif
void reportError(ErrorCode errCode, const char *format,...)
Definition: str.h:59
ErrorCode
Definition: error.h:47
Definition: error.h:50
static void fatalError(ErrorCode errCode, const char *format,...)
Definition: bagel.h:31