2010-04-11 19:04:02 +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.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
*
|
2010-04-11 19:04:02 +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
|
|
|
*
|
2010-04-11 19:04:02 +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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common/error.h"
|
|
|
|
|
2010-06-15 10:44:51 +00:00
|
|
|
#include "common/translation.h"
|
|
|
|
|
2010-04-11 19:04:02 +00:00
|
|
|
namespace Common {
|
|
|
|
|
|
|
|
/**
|
2011-04-18 15:39:31 +00:00
|
|
|
* Maps an error code to equivalent string description.
|
|
|
|
*
|
|
|
|
* @param errorCode error code to be converted
|
|
|
|
* @return a pointer to string description of the error
|
2010-04-11 19:04:02 +00:00
|
|
|
*/
|
2011-04-18 15:39:31 +00:00
|
|
|
static String errorToString(ErrorCode errorCode) {
|
|
|
|
switch (errorCode) {
|
|
|
|
case kNoError:
|
|
|
|
return _s("No error");
|
|
|
|
case kNoGameDataFoundError:
|
2011-04-18 15:43:19 +00:00
|
|
|
return _s("Game data not found");
|
2011-04-18 15:39:31 +00:00
|
|
|
case kUnsupportedGameidError:
|
2011-04-18 15:43:19 +00:00
|
|
|
return _s("Game id not supported");
|
2011-04-18 15:39:31 +00:00
|
|
|
case kUnsupportedColorMode:
|
2011-04-18 15:43:19 +00:00
|
|
|
return _s("Unsupported color mode");
|
2018-06-07 18:14:27 +00:00
|
|
|
case kAudioDeviceInitFailed:
|
|
|
|
return _s("Audio device initialization failed");
|
2011-04-18 15:39:31 +00:00
|
|
|
|
|
|
|
case kReadPermissionDenied:
|
|
|
|
return _s("Read permission denied");
|
|
|
|
case kWritePermissionDenied:
|
|
|
|
return _s("Write permission denied");
|
2010-04-11 19:04:02 +00:00
|
|
|
|
2011-04-18 15:39:31 +00:00
|
|
|
case kPathDoesNotExist:
|
2011-04-18 15:43:19 +00:00
|
|
|
return _s("Path does not exist");
|
2011-04-18 15:39:31 +00:00
|
|
|
case kPathNotDirectory:
|
|
|
|
return _s("Path not a directory");
|
|
|
|
case kPathNotFile:
|
|
|
|
return _s("Path not a file");
|
|
|
|
|
|
|
|
case kCreatingFileFailed:
|
|
|
|
return _s("Cannot create file");
|
|
|
|
case kReadingFailed:
|
2011-04-18 15:43:19 +00:00
|
|
|
return _s("Reading data failed");
|
2011-04-18 15:39:31 +00:00
|
|
|
case kWritingFailed:
|
|
|
|
return _s("Writing data failed");
|
|
|
|
|
2011-04-18 16:19:53 +00:00
|
|
|
case kEnginePluginNotFound:
|
|
|
|
return _s("Could not find suitable engine plugin");
|
|
|
|
case kEnginePluginNotSupportSaves:
|
2016-11-29 10:43:57 +00:00
|
|
|
return _s("Engine plugin does not support saved games");
|
2011-04-18 16:19:53 +00:00
|
|
|
|
2011-04-25 20:26:38 +00:00
|
|
|
case kUserCanceled:
|
|
|
|
return _s("User canceled");
|
|
|
|
|
2011-04-18 16:19:53 +00:00
|
|
|
case kUnknownError:
|
2011-04-18 15:39:31 +00:00
|
|
|
default:
|
2011-04-18 15:43:19 +00:00
|
|
|
return _s("Unknown error");
|
2010-04-11 19:04:02 +00:00
|
|
|
}
|
2011-04-18 15:39:31 +00:00
|
|
|
}
|
2010-04-11 19:04:02 +00:00
|
|
|
|
2011-04-18 15:39:31 +00:00
|
|
|
Error::Error(ErrorCode code)
|
|
|
|
: _code(code), _desc(errorToString(code)) {
|
2010-04-11 19:04:02 +00:00
|
|
|
}
|
|
|
|
|
2011-04-18 15:39:31 +00:00
|
|
|
Error::Error(ErrorCode code, const String &desc)
|
2011-04-18 15:45:35 +00:00
|
|
|
: _code(code), _desc(errorToString(code) + " (" + desc + ")") {
|
2011-04-18 15:39:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-04-11 19:04:02 +00:00
|
|
|
} // End of namespace Common
|