2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM 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.
|
2007-01-14 21:29:12 +00:00
|
|
|
*
|
|
|
|
* 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.
|
2014-02-18 01:34:18 +00:00
|
|
|
*
|
2007-01-14 21:29:12 +00:00
|
|
|
* 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.
|
2014-02-18 01:34:18 +00:00
|
|
|
*
|
2007-01-14 21:29:12 +00:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-09-18 20:02:04 +00:00
|
|
|
#ifndef COMMON_ERROR_H
|
|
|
|
#define COMMON_ERROR_H
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2011-04-18 15:39:31 +00:00
|
|
|
#include "common/str.h"
|
|
|
|
|
2008-11-06 16:40:00 +00:00
|
|
|
namespace Common {
|
2007-04-07 10:02:59 +00:00
|
|
|
|
2007-09-18 20:02:04 +00:00
|
|
|
/**
|
2008-11-06 16:40:00 +00:00
|
|
|
* This file contains an enum with commonly used error codes.
|
2007-09-18 20:02:04 +00:00
|
|
|
*/
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2008-11-06 16:40:00 +00:00
|
|
|
|
2008-11-05 17:24:56 +00:00
|
|
|
|
2008-02-01 23:36:45 +00:00
|
|
|
/**
|
|
|
|
* Error codes which may be reported by plugins under various circumstances.
|
2008-11-05 17:24:56 +00:00
|
|
|
*
|
2011-04-18 15:51:08 +00:00
|
|
|
* @note Error names should follow the pattern k-NOUN/ACTION-CONDITION-Error.
|
|
|
|
* So kPathInvalidError would be correct, but these would not be:
|
|
|
|
* kInvalidPath, kPathInvalid, kPathIsInvalid, kInvalidPathError.
|
|
|
|
* @todo Adjust all error codes to comply with these conventions.
|
2008-02-01 23:36:45 +00:00
|
|
|
*/
|
2011-04-18 15:39:31 +00:00
|
|
|
enum ErrorCode {
|
2010-06-15 12:33:20 +00:00
|
|
|
kNoError = 0, ///< No error occurred
|
2009-10-08 21:28:57 +00:00
|
|
|
kNoGameDataFoundError, ///< Engine initialization: No game data was found in the specified location
|
|
|
|
kUnsupportedGameidError, ///< Engine initialization: Gameid not supported by this (Meta)Engine
|
|
|
|
kUnsupportedColorMode, ///< Engine initialization: Engine does not support backend's color mode
|
2018-06-07 18:14:27 +00:00
|
|
|
kAudioDeviceInitFailed, ///< Engine initialization: Audio device initialization failed
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2009-10-08 21:28:57 +00:00
|
|
|
kReadPermissionDenied, ///< Unable to read data due to missing read permission
|
|
|
|
kWritePermissionDenied, ///< Unable to write data due to missing write permission
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2009-10-08 21:28:57 +00:00
|
|
|
kPathDoesNotExist, ///< The specified path does not exist
|
|
|
|
kPathNotDirectory, ///< The specified path does not point to a directory
|
|
|
|
kPathNotFile, ///< The specified path does not point to a file
|
2008-11-06 16:40:00 +00:00
|
|
|
|
2010-05-21 18:25:01 +00:00
|
|
|
kCreatingFileFailed, ///< Failed creating a (savestate) file
|
|
|
|
kReadingFailed, ///< Failed to read a file (permission denied?)
|
2009-10-08 21:28:57 +00:00
|
|
|
kWritingFailed, ///< Failure to write data -- disk full?
|
2008-02-01 23:36:45 +00:00
|
|
|
|
2010-05-21 18:25:01 +00:00
|
|
|
// The following are used by --list-saves
|
2011-04-18 16:19:53 +00:00
|
|
|
kEnginePluginNotFound, ///< Failed to find plugin to handle target
|
|
|
|
kEnginePluginNotSupportSaves, ///< Failed if plugin does not support listing save states
|
2010-05-21 18:25:01 +00:00
|
|
|
|
2011-04-25 20:26:38 +00:00
|
|
|
kUserCanceled, ///< User has canceled the launching of the game
|
|
|
|
|
2009-10-08 21:28:57 +00:00
|
|
|
kUnknownError ///< Catch-all error, used if no other error code matches
|
2008-02-01 23:36:45 +00:00
|
|
|
};
|
|
|
|
|
2010-04-11 19:04:02 +00:00
|
|
|
/**
|
2011-04-18 15:39:31 +00:00
|
|
|
* An Error instance pairs an error code with string description providing more
|
|
|
|
* details about the error. For every error code, a default description is
|
|
|
|
* provided, but it is possible to optionally augment that description with
|
|
|
|
* extra information when creating a new Error instance.
|
2010-04-11 19:04:02 +00:00
|
|
|
*/
|
2011-04-18 15:39:31 +00:00
|
|
|
class Error {
|
|
|
|
protected:
|
|
|
|
ErrorCode _code;
|
|
|
|
String _desc;
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Construct a new Error with the specified error code and the default
|
|
|
|
* error message.
|
|
|
|
*/
|
|
|
|
Error(ErrorCode code = kUnknownError);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Construct a new Error with the specified error code and an augmented
|
2011-04-18 15:45:35 +00:00
|
|
|
* error message. Specifically, the provided extra text is suitably
|
|
|
|
* appended to the default message.
|
2011-04-18 15:39:31 +00:00
|
|
|
*/
|
|
|
|
Error(ErrorCode code, const String &extra);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the description of this error.
|
|
|
|
*/
|
|
|
|
const String &getDesc() const { return _desc; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the error code of this error.
|
|
|
|
*/
|
|
|
|
ErrorCode getCode() const { return _code; }
|
|
|
|
};
|
2010-04-11 19:04:02 +00:00
|
|
|
|
2008-11-05 17:24:56 +00:00
|
|
|
} // End of namespace Common
|
|
|
|
|
2007-09-18 20:02:04 +00:00
|
|
|
#endif //COMMON_ERROR_H
|