DayZ 1.24
Loading...
Searching...
No Matches
ErrorHandlerModule.c
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2// Definition
3//-----------------------------------------------------------------------------
6{
9
12
14 protected void OnErrorThrown(int errorCode, owned string additionalInfo = "")
15 {
16#ifdef DEVELOPER
18#endif
19 }
20
22 string GetClientMessage(int errorCode, string additionalInfo = "")
23 {
25 }
26
29 {
31 }
32
34 string GetServerMessage(int errorCode, string additionalInfo = "")
35 {
37 }
38
41 {
43 }
44
46 string GetSimpleMessage(int errorCode, string additionalInfo = "")
47 {
49 }
50
55}
56
57//-----------------------------------------------------------------------------
58// Script override
59//-----------------------------------------------------------------------------
63class ErrorHandlerModuleScript : ErrorHandlerModule
64{
65 protected string m_Header = "";
66 protected string m_Prefix = "";
68
69 protected int m_LastErrorThrown = 0;
70 protected string m_LastAdditionalInfo = "";
71
79
86
88 {
89 if (m_UIHandler)
90 delete m_UIHandler;
91 }
92
95 {
96 }
97
100 {
102 InsertDialogueErrorProperties(-1, "#server_browser_error_unknown");
103 }
104
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 }
120
126 override string GetClientMessage(int errorCode, string additionalInfo = "")
127 {
129
130 if (properties)
131 return properties.GetClientMessage(additionalInfo);
132 else
133 return additionalInfo;
134 }
135
141 override string GetLastClientMessage(int errorCode)
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 }
151
157 override string GetServerMessage(int errorCode, string additionalInfo = "")
158 {
160
161 if (properties)
162 return properties.GetServerMessage(additionalInfo);
163 else
164 return additionalInfo;
165 }
166
172 override string GetLastServerMessage(int errorCode)
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 }
182
190 protected override void OnErrorThrown(int errorCode, owned string additionalInfo = "")
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 }
208
209 //-----------------------------------------------------------------------------
210 // Insert helpers
211 //-----------------------------------------------------------------------------
217
223
229
235
241
247
249 void InsertErrorProperties(int code, string message = "")
250 {
252 }
253}
override void InitOptionalVariables()
override void FillErrorDataMap()
proto string ToString()
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 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 ~ErrorHandlerModuleScript()
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!...
class ErrorHandlerModule m_Header
This is where to input logic and extend functionality of ErrorHandlerModule.
override string GetLastServerMessage(int errorCode)
Fetches the Server message for the error code, attempting to retrieve the data from the latest.
void ErrorHandlerModuleScript()
Constructor, by default calls the function that will fill the ErrorDataMap.
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.
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 GetLastClientMessage(int errorCode)
Fetches the Client message for the error code, attempting to retrieve the data from the latest.
ErrorProperties GetProperties(int errorCode)
Fetches the ErrorProperties for the error code.
ref UIScriptedMenu m_UIHandler
Optional: The UI the handler might generally use
ref map< int, ref ErrorProperties > m_ErrorDataMap
Map containing the codes that exist for the ErrorHandlerModule The code links to ErrorProperties This...
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.
override string GetClientMessage(int errorCode, string additionalInfo="")
Fetches the Client message for the error code.
override string GetServerMessage(int errorCode, string additionalInfo="")
Fetches the Server message for the error code.
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 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.
string m_Prefix
Optional: Prefix (e.g. Fixed text at the start of the messages in the module)
void InsertErrorProperties(int code, string message="")
Insert an error with no handling.
ErrorCategory
ErrorCategory - To decide what ErrorHandlerModule needs to be called and easily identify where it cam...
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)
int GetCategory()
Definition and API of an ErrorHandlerModule - Do not insert any logic here! (as this class is not mod...
proto native ErrorCategory GetCategory()
Returns the category the module handles.
void OnErrorThrown(int errorCode, owned string additionalInfo="")
Event that gets triggered when an error of the owned category is thrown.
string GetLastServerMessage(int errorCode)
Retrieve the message shown on Server.
proto native void SetCategory(ErrorCategory category)
Set the category the module handles.
string GetClientMessage(int errorCode, string additionalInfo="")
Retrieve the message shown on Client.
string GetLastClientMessage(int errorCode)
Retrieve the message shown on Client.
string GetSimpleMessage(int errorCode, string additionalInfo="")
Simple message of just code and info.
string GetServerMessage(int errorCode, string additionalInfo="")
Retrieve the message shown on Server.
void OnEvent(EventType eventTypeId, Param params)
Event called by ErrorModuleHandler.
The error handler itself, for managing and distributing errors to modules Manages the ErrorHandlerMod...
static proto int GetCodeFromError(int errorCode)
Returns the code of the error.
static proto owned string GetErrorHex(int errorCode)
Returns a formatted string of the error code.
Class which holds the properties and handling of an error.
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
ErrorExSeverity
Definition EnDebug.c:62
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
proto void Print(void var)
Prints content of variable to console/log.
enum ShapeType ErrorEx
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.