DayZ 1.24
Loading...
Searching...
No Matches
ErrorHandlerModule.c File Reference

Go to the source code of this file.

Classes

class  ErrorHandlerModule
 Definition and API of an ErrorHandlerModule - Do not insert any logic here! (as this class is not moddable) More...
 

Functions

void ErrorHandlerModuleScript ()
 Constructor, by default calls the function that will fill the ErrorDataMap.
 
void ~ErrorHandlerModuleScript ()
 
void InitOptionalVariables ()
 Function which gets called before FillErrorDataMap, designed to set Optional Variales before ErrorProperties are created.
 
void FillErrorDataMap ()
 Function to fill up m_ErrorDataMap, gets called in the Constructor.
 
ErrorProperties GetProperties (int errorCode)
 Fetches the ErrorProperties for the error code.
 
override string GetClientMessage (int errorCode, string additionalInfo="")
 Fetches the Client message for the error code.
 
override string GetLastClientMessage (int errorCode)
 Fetches the Client message for the error code, attempting to retrieve the data from the latest.
 
override string GetServerMessage (int errorCode, string additionalInfo="")
 Fetches the Server message for the error code.
 
override string GetLastServerMessage (int errorCode)
 Fetches the Server message for the error code, attempting to retrieve the data from the latest.
 
override void OnErrorThrown (int errorCode, owned string additionalInfo="")
 Event that gets triggered when an error of the owned category is thrown. Do not call directly! Call ErrorModuleHandler.ThrowError instead.
 
void InsertDialogueErrorProperties (int code, string message, int dialogButtonType=DBT_OK, int defaultButton=DBB_OK, int dialogMeaningType=DMT_EXCLAMATION, bool displayAdditionalInfo=true)
 Insert an error with Dialogue as handling, using the Optional Variables.
 
void InsertHeaderDialogueErrorProperties (int code, string message, string header, int dialogButtonType=DBT_OK, int defaultButton=DBB_OK, int dialogMeaningType=DMT_EXCLAMATION, bool displayAdditionalInfo=true)
 Insert an error with Dialogue as handling with custom header.
 
void InsertPrefixDialogueErrorProperties (int code, string message, string prefix, int dialogButtonType=DBT_OK, int defaultButton=DBB_OK, int dialogMeaningType=DMT_EXCLAMATION, bool displayAdditionalInfo=true)
 Insert an error with Dialogue as handling with custom prefix.
 
void InsertExtendedPrefixDialogueErrorProperties (int code, string message, string prefix, int dialogButtonType=DBT_OK, int defaultButton=DBB_OK, int dialogMeaningType=DMT_EXCLAMATION, bool displayAdditionalInfo=true)
 Insert an error with Dialogue as handling with extended prefix.
 
void InsertExtendedPrefixSplitDialogueErrorProperties (int code, string message, string prefix, string serverMessage, int dialogButtonType=DBT_OK, int defaultButton=DBB_OK, int dialogMeaningType=DMT_EXCLAMATION, bool displayAdditionalInfo=true)
 Insert an error with Dialogue as handling with extended prefix and separate server message.
 
void InsertSplitDialogueErrorProperties (int code, string message, string serverMessage, int dialogButtonType=DBT_OK, int defaultButton=DBB_OK, int dialogMeaningType=DMT_EXCLAMATION, bool displayAdditionalInfo=true)
 Insert an error with Dialogue as handling with separate server message.
 
void InsertErrorProperties (int code, string message="")
 Insert an error with no handling.
 

Variables

class ErrorHandlerModule m_Header = ""
 This is where to input logic and extend functionality of ErrorHandlerModule.
 
string m_Prefix = ""
 Optional: Prefix (e.g. Fixed text at the start of the messages in the module)
 
ref UIScriptedMenu m_UIHandler = null
 Optional: The UI the handler might generally use
 
int m_LastErrorThrown = 0
 Holds the last thrown error in this module, defaults to 0.
 
string m_LastAdditionalInfo = ""
 Holds the last additional info passed in.
 
ref map< int, ref ErrorPropertiesm_ErrorDataMap = new map<int, ref ErrorProperties>()
 Map containing the codes that exist for the ErrorHandlerModule The code links to ErrorProperties This contains at the very least the Message for the error Additionally, it can contain the way to handle the error (e.g. Throw a Dialogue with the message)
 

Function Documentation

◆ ErrorHandlerModuleScript()

void ErrorHandlerModuleScript ( )
protected

Constructor, by default calls the function that will fill the ErrorDataMap.

Definition at line 81 of file ErrorHandlerModule.c.

82 {
85 }
void FillErrorDataMap()
Function to fill up m_ErrorDataMap, gets called in the Constructor.
void InitOptionalVariables()
Function which gets called before FillErrorDataMap, designed to set Optional Variales before ErrorPro...

References FillErrorDataMap(), and InitOptionalVariables().

◆ FillErrorDataMap()

void FillErrorDataMap ( )
protected

Function to fill up m_ErrorDataMap, gets called in the Constructor.

Already insert the default "UNKNOWN ERROR" message for code "-1"

Definition at line 99 of file ErrorHandlerModule.c.

100 {
102 InsertDialogueErrorProperties(-1, "#server_browser_error_unknown");
103 }
void InsertDialogueErrorProperties(int code, string message, int dialogButtonType=DBT_OK, int defaultButton=DBB_OK, int dialogMeaningType=DMT_EXCLAMATION, bool displayAdditionalInfo=true)
Insert an error with Dialogue as handling, using the Optional Variables.

References InsertDialogueErrorProperties().

◆ GetClientMessage()

override string GetClientMessage ( int errorCode,
string additionalInfo = "" )
protected

Fetches the Client message for the error code.

Parameters
errorCodeint The full error code
Returns
string The Client message for the error

Definition at line 126 of file ErrorHandlerModule.c.

127 {
129
130 if (properties)
131 return properties.GetClientMessage(additionalInfo);
132 else
133 return additionalInfo;
134 }
ErrorProperties GetProperties(int errorCode)
Fetches the ErrorProperties for the error code.
Class which holds the properties and handling of an error.

References GetProperties().

Referenced by GetLastClientMessage().

◆ GetLastClientMessage()

override string GetLastClientMessage ( int errorCode)
protected

Fetches the Client message for the error code, attempting to retrieve the data from the latest.

Parameters
errorCodeint The full error code to check against
Returns
string The Client message for the error

Definition at line 141 of file ErrorHandlerModule.c.

142 {
145 else
146 {
147 ErrorEx(string.Format("Was unable to get the information on the last error as another has already occurred. (%1 != %2)", ErrorModuleHandler.GetErrorHex(errorCode), ErrorModuleHandler.GetErrorHex(m_LastErrorThrown)));
149 }
150 }
string m_LastAdditionalInfo
Holds the last additional info passed in.
int m_LastErrorThrown
Holds the last thrown error in this module, defaults to 0.
override string GetClientMessage(int errorCode, string additionalInfo="")
Fetches the Client message for the error code.
The error handler itself, for managing and distributing errors to modules Manages the ErrorHandlerMod...
static proto owned string GetErrorHex(int errorCode)
Returns a formatted string of the error code.
enum ShapeType ErrorEx

References ErrorEx, GetClientMessage(), ErrorModuleHandler::GetErrorHex(), m_LastAdditionalInfo, and m_LastErrorThrown.

◆ GetLastServerMessage()

override string GetLastServerMessage ( int errorCode)
protected

Fetches the Server message for the error code, attempting to retrieve the data from the latest.

Parameters
errorCodeint The full error code to check against
Returns
string The Server message for the error

Definition at line 172 of file ErrorHandlerModule.c.

173 {
176 else
177 {
178 ErrorEx(string.Format("Was unable to get the information on the last error as another has already occurred. (%1 != %2)", ErrorModuleHandler.GetErrorHex(errorCode), ErrorModuleHandler.GetErrorHex(m_LastErrorThrown)), ErrorExSeverity.WARNING);
180 }
181 }
override string GetServerMessage(int errorCode, string additionalInfo="")
Fetches the Server message for the error code.
ErrorExSeverity
Definition EnDebug.c:62

References ErrorEx, ErrorModuleHandler::GetErrorHex(), GetServerMessage(), m_LastAdditionalInfo, and m_LastErrorThrown.

◆ GetProperties()

ErrorProperties GetProperties ( int errorCode)
protected

Fetches the ErrorProperties for the error code.

Parameters
errorCodeint The full error code
Returns
ErrorProperties The data and handling for the error

Definition at line 110 of file ErrorHandlerModule.c.

111 {
114
115 if (!m_ErrorDataMap.Find(error, properties))
116 Error(string.Format("[EHM] Could not find any properties for error %1(%2) in %3", errorCode, ErrorModuleHandler.GetErrorHex(errorCode), this));
117
118 return properties;
119 }
ref map< int, ref ErrorProperties > m_ErrorDataMap
Map containing the codes that exist for the ErrorHandlerModule The code links to ErrorProperties This...
static proto int GetCodeFromError(int errorCode)
Returns the code of the error.
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90

References Error(), ErrorModuleHandler::GetCodeFromError(), ErrorModuleHandler::GetErrorHex(), and m_ErrorDataMap.

Referenced by GetClientMessage(), GetServerMessage(), and OnErrorThrown().

◆ GetServerMessage()

override string GetServerMessage ( int errorCode,
string additionalInfo = "" )
protected

Fetches the Server message for the error code.

Parameters
errorCodeint The full error code
Returns
string The Server message for the error

Definition at line 157 of file ErrorHandlerModule.c.

158 {
160
161 if (properties)
162 return properties.GetServerMessage(additionalInfo);
163 else
164 return additionalInfo;
165 }

References GetProperties().

Referenced by GetLastServerMessage().

◆ InitOptionalVariables()

void InitOptionalVariables ( )
protected

Function which gets called before FillErrorDataMap, designed to set Optional Variales before ErrorProperties are created.

Definition at line 94 of file ErrorHandlerModule.c.

95 {
96 }

◆ InsertDialogueErrorProperties()

void InsertDialogueErrorProperties ( int code,
string message,
int dialogButtonType = DBT_OK,
int defaultButton = DBB_OK,
int dialogMeaningType = DMT_EXCLAMATION,
bool displayAdditionalInfo = true )
protected

Insert an error with Dialogue as handling, using the Optional Variables.

Definition at line 213 of file ErrorHandlerModule.c.

214 {
216 }
class ErrorHandlerModule m_Header
This is where to input logic and extend functionality of ErrorHandlerModule.
ref UIScriptedMenu m_UIHandler
Optional: The UI the handler might generally use
string m_Prefix
Optional: Prefix (e.g. Fixed text at the start of the messages in the module)
void DialogueErrorProperties(string message, string serverMessage, string header, UIScriptedMenu handler=null, int dialogButtonType=DBT_OK, int defaultButton=DBB_OK, int dialogMeaningType=DMT_EXCLAMATION, bool displayAdditionalInfo=true)

References DialogueErrorProperties(), m_ErrorDataMap, m_Header, m_Prefix, and m_UIHandler.

Referenced by ClientKickedModule::FillErrorDataMap(), ConnectErrorClientModule::FillErrorDataMap(), FillErrorDataMap(), ConnectErrorServerModule::FillErrorDataMap(), and BIOSErrorModule::InsertBIOSError().

◆ InsertErrorProperties()

void InsertErrorProperties ( int code,
string message = "" )
protected

◆ InsertExtendedPrefixDialogueErrorProperties()

void InsertExtendedPrefixDialogueErrorProperties ( int code,
string message,
string prefix,
int dialogButtonType = DBT_OK,
int defaultButton = DBB_OK,
int dialogMeaningType = DMT_EXCLAMATION,
bool displayAdditionalInfo = true )
protected

Insert an error with Dialogue as handling with extended prefix.

Definition at line 231 of file ErrorHandlerModule.c.

References DialogueErrorProperties(), m_ErrorDataMap, m_Header, m_Prefix, and m_UIHandler.

Referenced by ClientKickedModule::FillErrorDataMap().

◆ InsertExtendedPrefixSplitDialogueErrorProperties()

void InsertExtendedPrefixSplitDialogueErrorProperties ( int code,
string message,
string prefix,
string serverMessage,
int dialogButtonType = DBT_OK,
int defaultButton = DBB_OK,
int dialogMeaningType = DMT_EXCLAMATION,
bool displayAdditionalInfo = true )
protected

Insert an error with Dialogue as handling with extended prefix and separate server message.

Definition at line 237 of file ErrorHandlerModule.c.

References DialogueErrorProperties(), m_ErrorDataMap, m_Header, m_Prefix, and m_UIHandler.

Referenced by ClientKickedModule::FillErrorDataMap().

◆ InsertHeaderDialogueErrorProperties()

void InsertHeaderDialogueErrorProperties ( int code,
string message,
string header,
int dialogButtonType = DBT_OK,
int defaultButton = DBB_OK,
int dialogMeaningType = DMT_EXCLAMATION,
bool displayAdditionalInfo = true )
protected

Insert an error with Dialogue as handling with custom header.

Definition at line 219 of file ErrorHandlerModule.c.

References DialogueErrorProperties(), m_ErrorDataMap, m_Prefix, and m_UIHandler.

◆ InsertPrefixDialogueErrorProperties()

void InsertPrefixDialogueErrorProperties ( int code,
string message,
string prefix,
int dialogButtonType = DBT_OK,
int defaultButton = DBB_OK,
int dialogMeaningType = DMT_EXCLAMATION,
bool displayAdditionalInfo = true )
protected

Insert an error with Dialogue as handling with custom prefix.

Definition at line 225 of file ErrorHandlerModule.c.

References DialogueErrorProperties(), m_ErrorDataMap, m_Header, and m_UIHandler.

Referenced by ClientKickedModule::FillErrorDataMap().

◆ InsertSplitDialogueErrorProperties()

void InsertSplitDialogueErrorProperties ( int code,
string message,
string serverMessage,
int dialogButtonType = DBT_OK,
int defaultButton = DBB_OK,
int dialogMeaningType = DMT_EXCLAMATION,
bool displayAdditionalInfo = true )
protected

Insert an error with Dialogue as handling with separate server message.

Definition at line 243 of file ErrorHandlerModule.c.

References DialogueErrorProperties(), m_ErrorDataMap, m_Header, m_Prefix, and m_UIHandler.

Referenced by ClientKickedModule::FillErrorDataMap().

◆ OnErrorThrown()

override void OnErrorThrown ( int errorCode,
owned string additionalInfo = "" )
protected

Event that gets triggered when an error of the owned category is thrown. Do not call directly! Call ErrorModuleHandler.ThrowError instead.

Parameters
errorCodeint The full error code
additionalInfostring Any additional info regarding the error, usually data

Definition at line 190 of file ErrorHandlerModule.c.

191 {
192 super.OnErrorThrown(errorCode, additionalInfo);
193
196
198
199 if (properties)
200 properties.HandleError(errorCode, additionalInfo);
201 else
202 {
203 ErrorEx(string.Format("Error code %1(%2) was thrown but no ErrorProperties was found for it in category %3.", errorCode, ErrorModuleHandler.GetErrorHex(errorCode), GetCategory().ToString()));
204 if (m_ErrorDataMap.Find(-1, properties))
205 properties.HandleError(errorCode, additionalInfo);
206 }
207 }
proto string ToString()
int GetCategory()

References ErrorEx, GetCategory(), ErrorModuleHandler::GetErrorHex(), GetProperties(), m_ErrorDataMap, m_LastAdditionalInfo, m_LastErrorThrown, and ToString().

◆ ~ErrorHandlerModuleScript()

Definition at line 87 of file ErrorHandlerModule.c.

88 {
89 if (m_UIHandler)
90 delete m_UIHandler;
91 }

References m_UIHandler.

Variable Documentation

◆ m_ErrorDataMap

ref map<int, ref ErrorProperties> m_ErrorDataMap = new map<int, ref ErrorProperties>()
protected

Map containing the codes that exist for the ErrorHandlerModule The code links to ErrorProperties This contains at the very least the Message for the error Additionally, it can contain the way to handle the error (e.g. Throw a Dialogue with the message)

Definition at line 78 of file ErrorHandlerModule.c.

Referenced by GetProperties(), InsertDialogueErrorProperties(), InsertErrorProperties(), InsertExtendedPrefixDialogueErrorProperties(), InsertExtendedPrefixSplitDialogueErrorProperties(), InsertHeaderDialogueErrorProperties(), InsertPrefixDialogueErrorProperties(), InsertSplitDialogueErrorProperties(), and OnErrorThrown().

◆ m_Header

◆ m_LastAdditionalInfo

string m_LastAdditionalInfo = ""
protected

Holds the last additional info passed in.

Definition at line 70 of file ErrorHandlerModule.c.

Referenced by GetLastClientMessage(), GetLastServerMessage(), and OnErrorThrown().

◆ m_LastErrorThrown

int m_LastErrorThrown = 0
protected

Holds the last thrown error in this module, defaults to 0.

Definition at line 69 of file ErrorHandlerModule.c.

Referenced by GetLastClientMessage(), GetLastServerMessage(), OnErrorThrown(), ConnectErrorClientModule::OnEvent(), OnEvent(), and ConnectErrorServerModule::OnEvent().

◆ m_Prefix

◆ m_UIHandler