Class that handles all error related functions. More...
#include <script_error.hpp>
Public Types | |
enum | ErrorCategories { ERR_CAT_NONE = 0, ERR_CAT_GENERAL, ERR_CAT_VEHICLE, ERR_CAT_STATION, ERR_CAT_BRIDGE, ERR_CAT_TUNNEL, ERR_CAT_TILE, ERR_CAT_SIGN, ERR_CAT_RAIL, ERR_CAT_ROAD, ERR_CAT_ORDER, ERR_CAT_MARINE, ERR_CAT_WAYPOINT, ERR_CAT_BIT_SIZE = 8 } |
All categories errors can be divided in. More... | |
enum | ErrorMessages { ERR_NONE = ERR_CAT_NONE << ERR_CAT_BIT_SIZE, ERR_UNKNOWN, ERR_PRECONDITION_FAILED, ERR_PRECONDITION_STRING_TOO_LONG, ERR_NEWGRF_SUPPLIED_ERROR, ERR_GENERAL_BASE = ERR_CAT_GENERAL << ERR_CAT_BIT_SIZE, ERR_NOT_ENOUGH_CASH, ERR_LOCAL_AUTHORITY_REFUSES, ERR_ALREADY_BUILT, ERR_AREA_NOT_CLEAR, ERR_OWNED_BY_ANOTHER_COMPANY, ERR_NAME_IS_NOT_UNIQUE, ERR_FLAT_LAND_REQUIRED, ERR_LAND_SLOPED_WRONG, ERR_VEHICLE_IN_THE_WAY, ERR_SITE_UNSUITABLE, ERR_TOO_CLOSE_TO_EDGE, ERR_STATION_TOO_SPREAD_OUT } |
All general related error messages. More... | |
Static Public Member Functions | |
static ErrorCategories | GetErrorCategory () |
Check the membership of the last thrown error. | |
static ScriptErrorType | GetLastError () |
Get the last error. | |
static char * | GetLastErrorString () |
Get the last error in string format (for human readability). | |
static ScriptErrorType | StringToError (StringID internal_string_id) |
Get the error based on the OpenTTD StringID. | |
static void | RegisterErrorMap (StringID internal_string_id, ScriptErrorType ai_error_msg) |
Map an internal OpenTTD error message to its NoAI equivalent. | |
static void | RegisterErrorMapString (ScriptErrorType ai_error_msg, const char *message) |
Map an internal OpenTTD error message to its NoAI equivalent. | |
Private Types | |
typedef std::map< StringID, ScriptErrorType > | ScriptErrorMap |
The type for mapping between error (internal OpenTTD) StringID to the AI error type. | |
typedef std::map < ScriptErrorType, const char * > | ScriptErrorMapString |
The type for mapping between error type and textual representation. | |
Static Private Attributes | |
static ScriptErrorMap | error_map = ScriptError::ScriptErrorMap() |
The mapping between error (internal OpenTTD) StringID to the AI error type. | |
static ScriptErrorMapString | error_map_string = ScriptError::ScriptErrorMapString() |
The mapping between error type and textual representation. |
Class that handles all error related functions.
ai
Definition at line 45 of file script_error.hpp.
All categories errors can be divided in.
Definition at line 50 of file script_error.hpp.
All general related error messages.
ERR_NONE |
Initial error value. |
ERR_UNKNOWN |
If an error occurred and the error wasn't mapped. |
ERR_PRECONDITION_FAILED |
If a precondition is not met. |
ERR_PRECONDITION_STRING_TOO_LONG |
A string supplied was too long. |
ERR_NEWGRF_SUPPLIED_ERROR |
An error returned by a NewGRF. No possibility to get the exact error in an AI readable format |
ERR_GENERAL_BASE |
Base for general errors. |
ERR_NOT_ENOUGH_CASH |
Not enough cash to perform the previous action. |
ERR_LOCAL_AUTHORITY_REFUSES |
Local authority won't allow the previous action. |
ERR_ALREADY_BUILT |
The piece of infrastructure you tried to build is already in place. |
ERR_AREA_NOT_CLEAR |
Area isn't clear, try to demolish the building on it. |
ERR_OWNED_BY_ANOTHER_COMPANY |
Area / property is owned by another company. |
ERR_NAME_IS_NOT_UNIQUE |
The name given is not unique for the object type. |
ERR_FLAT_LAND_REQUIRED |
The building you want to build requires flat land. |
ERR_LAND_SLOPED_WRONG |
Land is sloped in the wrong direction for this build action. |
ERR_VEHICLE_IN_THE_WAY |
A vehicle is in the way. |
ERR_SITE_UNSUITABLE |
Site is unsuitable. |
ERR_TOO_CLOSE_TO_EDGE |
Too close to the edge of the map. |
ERR_STATION_TOO_SPREAD_OUT |
Station is too spread out. |
Definition at line 75 of file script_error.hpp.
ScriptError::ErrorCategories ScriptError::GetErrorCategory | ( | ) | [static] |
Check the membership of the last thrown error.
Definition at line 65 of file script_error.cpp.
References ERR_CAT_BIT_SIZE, and GetLastError().
ScriptErrorType ScriptError::GetLastError | ( | ) | [static] |
Get the last error.
Reimplemented from ScriptObject.
Definition at line 19 of file script_error.cpp.
Referenced by GetErrorCategory(), and GetLastErrorString().
char * ScriptError::GetLastErrorString | ( | ) | [static] |
Get the last error in string format (for human readability).
Definition at line 24 of file script_error.cpp.
References error_map_string, and GetLastError().
void ScriptError::RegisterErrorMap | ( | StringID | internal_string_id, | |
ScriptErrorType | ai_error_msg | |||
) | [static] |
Map an internal OpenTTD error message to its NoAI equivalent.
-all
internal_string_id | The OpenTTD StringID used for an error. | |
ai_error_msg | The NoAI equivalent error message. |
Definition at line 55 of file script_error.cpp.
References error_map.
void ScriptError::RegisterErrorMapString | ( | ScriptErrorType | ai_error_msg, | |
const char * | message | |||
) | [static] |
Map an internal OpenTTD error message to its NoAI equivalent.
-all
ai_error_msg | The NoAI error message representation. | |
message | The string representation of this error message, used for debug purposes. |
Definition at line 60 of file script_error.cpp.
References error_map_string.
ScriptErrorType ScriptError::StringToError | ( | StringID | internal_string_id | ) | [static] |
Get the error based on the OpenTTD StringID.
-all
internal_string_id | The string to convert. |
Definition at line 29 of file script_error.cpp.
References ERR_UNKNOWN, error_map, and GB().
Referenced by ScriptObject::DoCommand(), and ScriptInstance::DoCommandCallback().