DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ErrorHandlerModule.c
См. документацию.
1//-----------------------------------------------------------------------------
2// Definition
3//-----------------------------------------------------------------------------
6{
8 proto native ErrorCategory GetCategory();
9
11 proto native void SetCategory(ErrorCategory category);
12
14 protected void OnErrorThrown(int errorCode, owned string additionalInfo = "")
15 {
16 #ifdef ENABLE_LOGGING
18 #endif
19 }
20
22 string GetClientMessage(int errorCode, string additionalInfo = "")
23 {
24 return GetSimpleMessage(errorCode, additionalInfo);
25 }
26
28 string GetLastClientMessage(int errorCode)
29 {
30 return GetSimpleMessage(errorCode);
31 }
32
34 string GetServerMessage(int errorCode, string additionalInfo = "")
35 {
36 return GetSimpleMessage(errorCode, additionalInfo);
37 }
38
40 string GetLastServerMessage(int errorCode)
41 {
42 return GetSimpleMessage(errorCode);
43 }
44
46 string GetSimpleMessage(int errorCode, string additionalInfo = "")
47 {
48 return string.Format("[%1]: %2", ErrorModuleHandler.GetErrorHex(errorCode), additionalInfo);
49 }
50
52 void OnEvent(EventType eventTypeId, Param params)
53 {
54 }
55}
56
57//-----------------------------------------------------------------------------
58// Script override
59//-----------------------------------------------------------------------------
64{
65 protected string m_Header = "";
66 protected string m_Prefix = "";
67 protected ref UIScriptedMenu m_UIHandler = null;
68
69 protected int m_LastErrorThrown = 0;
70 protected string m_LastAdditionalInfo = "";
71
79
86
88 {
89 if (m_UIHandler)
90 {
91 delete m_UIHandler;
92 }
93 }
94
97 {
98 }
99
102 {
104 InsertDialogueErrorProperties(-1, "#server_browser_error_unknown");
105 }
106
113 {
114 int error = ErrorModuleHandler.GetCodeFromError(errorCode);
115 ErrorProperties properties = null;
116
117 if (!m_ErrorDataMap.Find(error, properties))
118 {
119 Error(string.Format("[EHM] Could not find any properties for error %1(%2) in %3", errorCode, ErrorModuleHandler.GetErrorHex(errorCode), this));
120 }
121
122 return properties;
123 }
124
130 override string GetClientMessage(int errorCode, string additionalInfo = "")
131 {
132 ErrorProperties properties = GetProperties(errorCode);
133
134 if ( properties )
135 {
136 return properties.GetClientMessage(additionalInfo);
137 }
138 else
139 {
140 return additionalInfo;
141 }
142 }
143
149 override string GetLastClientMessage(int errorCode)
150 {
151 if (errorCode == m_LastErrorThrown)
152 {
153 return GetClientMessage(errorCode, m_LastAdditionalInfo);
154 }
155 else
156 {
157 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)));
158 return GetClientMessage(errorCode);
159 }
160 }
161
167 override string GetServerMessage(int errorCode, string additionalInfo = "")
168 {
169 ErrorProperties properties = GetProperties(errorCode);
170
171 if ( properties )
172 {
173 return properties.GetServerMessage(additionalInfo);
174 }
175 else
176 {
177 return additionalInfo;
178 }
179 }
180
186 override string GetLastServerMessage(int errorCode)
187 {
188 if (errorCode == m_LastErrorThrown)
189 {
190 return GetServerMessage(errorCode, m_LastAdditionalInfo);
191 }
192 else
193 {
194 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);
195 return GetServerMessage(errorCode);
196 }
197 }
198
206 protected override void OnErrorThrown(int errorCode, owned string additionalInfo = "")
207 {
208 super.OnErrorThrown(errorCode, additionalInfo);
209
210 m_LastErrorThrown = errorCode;
211 m_LastAdditionalInfo = additionalInfo;
212
213 ErrorProperties properties = GetProperties(errorCode);
214
215 if ( properties )
216 {
217 properties.HandleError(errorCode, additionalInfo);
218 }
219 else
220 {
221 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()));
222 if (m_ErrorDataMap.Find(-1, properties))
223 {
224 properties.HandleError(errorCode, additionalInfo);
225 }
226 }
227 }
228
229 //-----------------------------------------------------------------------------
230 // Insert helpers
231 //-----------------------------------------------------------------------------
233 void InsertDialogueErrorProperties(int code, string message, int dialogButtonType = DBT_OK, int defaultButton = DBB_OK, int dialogMeaningType = DMT_EXCLAMATION, bool displayAdditionalInfo = true)
234 {
235 m_ErrorDataMap.Insert(code, DialogueErrorProperties(string.Format("%1%2", m_Prefix, message), message, m_Header, m_UIHandler, dialogButtonType, defaultButton, dialogMeaningType, displayAdditionalInfo));
236 }
237
239 void InsertHeaderDialogueErrorProperties(int code, string message, string header, int dialogButtonType = DBT_OK, int defaultButton = DBB_OK, int dialogMeaningType = DMT_EXCLAMATION, bool displayAdditionalInfo = true)
240 {
241 m_ErrorDataMap.Insert(code, DialogueErrorProperties(string.Format("%1%2", m_Prefix, message), message, header, m_UIHandler, dialogButtonType, defaultButton, dialogMeaningType, displayAdditionalInfo));
242 }
243
245 void InsertPrefixDialogueErrorProperties(int code, string message, string prefix, int dialogButtonType = DBT_OK, int defaultButton = DBB_OK, int dialogMeaningType = DMT_EXCLAMATION, bool displayAdditionalInfo = true)
246 {
247 m_ErrorDataMap.Insert(code, DialogueErrorProperties(string.Format("%1%2", prefix, message), message, m_Header, m_UIHandler, dialogButtonType, defaultButton, dialogMeaningType, displayAdditionalInfo));
248 }
249
251 void InsertExtendedPrefixDialogueErrorProperties(int code, string message, string prefix, int dialogButtonType = DBT_OK, int defaultButton = DBB_OK, int dialogMeaningType = DMT_EXCLAMATION, bool displayAdditionalInfo = true)
252 {
253 m_ErrorDataMap.Insert(code, DialogueErrorProperties(string.Format("%1%2%3", m_Prefix, prefix, message), message, m_Header, m_UIHandler, dialogButtonType, defaultButton, dialogMeaningType, displayAdditionalInfo));
254 }
255
257 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)
258 {
259 m_ErrorDataMap.Insert(code, DialogueErrorProperties(string.Format("%1%2%3", m_Prefix, prefix, message), serverMessage, m_Header, m_UIHandler, dialogButtonType, defaultButton, dialogMeaningType, displayAdditionalInfo));
260 }
261
263 void InsertSplitDialogueErrorProperties(int code, string message, string serverMessage, int dialogButtonType = DBT_OK, int defaultButton = DBB_OK, int dialogMeaningType = DMT_EXCLAMATION, bool displayAdditionalInfo = true)
264 {
265 m_ErrorDataMap.Insert(code, DialogueErrorProperties(string.Format("%1%2", m_Prefix, message), serverMessage, m_Header, m_UIHandler, dialogButtonType, defaultButton, dialogMeaningType, displayAdditionalInfo));
266 }
267
269 void InsertErrorProperties(int code, string message = "")
270 {
271 m_ErrorDataMap.Insert(code, ErrorProperties(message, message));
272 }
273}
override void InitOptionalVariables()
Определения ConnectErrorScriptModule.c:17
override void FillErrorDataMap()
Определения ConnectErrorScriptModule.c:27
map
Определения ControlsXboxNew.c:4
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.
Определения ErrorHandlerModule.c:251
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.
Определения ErrorHandlerModule.c:263
void ~ErrorHandlerModuleScript()
Определения ErrorHandlerModule.c:87
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!...
Определения ErrorHandlerModule.c:206
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.
Определения ErrorHandlerModule.c:186
void ErrorHandlerModuleScript()
Constructor, by default calls the function that will fill the ErrorDataMap.
Определения ErrorHandlerModule.c:81
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.
Определения ErrorHandlerModule.c:257
string m_LastAdditionalInfo
Holds the last additional info passed in.
Определения ErrorHandlerModule.c:70
int m_LastErrorThrown
Holds the last thrown error in this module, defaults to 0.
Определения ErrorHandlerModule.c:69
override string GetLastClientMessage(int errorCode)
Fetches the Client message for the error code, attempting to retrieve the data from the latest.
Определения ErrorHandlerModule.c:149
ErrorProperties GetProperties(int errorCode)
Fetches the ErrorProperties for the error code.
Определения ErrorHandlerModule.c:112
ref UIScriptedMenu m_UIHandler
Optional: The UI the handler might generally use
Определения ErrorHandlerModule.c:67
ref map< int, ref ErrorProperties > m_ErrorDataMap
Map containing the codes that exist for the ErrorHandlerModule The code links to ErrorProperties This...
Определения ErrorHandlerModule.c:78
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.
Определения ErrorHandlerModule.c:239
override string GetClientMessage(int errorCode, string additionalInfo="")
Fetches the Client message for the error code.
Определения ErrorHandlerModule.c:130
override string GetServerMessage(int errorCode, string additionalInfo="")
Fetches the Server message for the error code.
Определения ErrorHandlerModule.c:167
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.
Определения ErrorHandlerModule.c:233
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.
Определения ErrorHandlerModule.c:245
string m_Prefix
Optional: Prefix (e.g. Fixed text at the start of the messages in the module)
Определения ErrorHandlerModule.c:66
void InsertErrorProperties(int code, string message="")
Insert an error with no handling.
Определения ErrorHandlerModule.c:269
ErrorCategory
ErrorCategory - To decide what ErrorHandlerModule needs to be called and easily identify where it cam...
Определения ErrorModuleHandler.c:5
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)
Определения ErrorProperties.c:45
int GetCategory()
Определения PluginDayzPlayerDebug.c:81
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.
Определения ErrorHandlerModule.c:14
string GetLastServerMessage(int errorCode)
Retrieve the message shown on Server.
Определения ErrorHandlerModule.c:40
proto native void SetCategory(ErrorCategory category)
Set the category the module handles.
string GetClientMessage(int errorCode, string additionalInfo="")
Retrieve the message shown on Client.
Определения ErrorHandlerModule.c:22
string GetLastClientMessage(int errorCode)
Retrieve the message shown on Client.
Определения ErrorHandlerModule.c:28
string GetSimpleMessage(int errorCode, string additionalInfo="")
Simple message of just code and info.
Определения ErrorHandlerModule.c:46
string GetServerMessage(int errorCode, string additionalInfo="")
Retrieve the message shown on Server.
Определения ErrorHandlerModule.c:34
void OnEvent(EventType eventTypeId, Param params)
Event called by ErrorModuleHandler.
Определения ErrorHandlerModule.c:52
Definition and API of an ErrorHandlerModule - Do not insert any logic here! (as this class is not mod...
Определения ErrorHandlerModule.c:6
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.
The error handler itself, for managing and distributing errors to modules Manages the ErrorHandlerMod...
Определения ErrorModuleHandler.c:29
string GetClientMessage(string additionalInfo="")
Определения ErrorProperties.c:18
void HandleError(int errorCode, string additionalInfo="")
Определения ErrorProperties.c:16
string GetServerMessage(string additionalInfo="")
Определения ErrorProperties.c:26
Class which holds the properties and handling of an error.
Определения ErrorProperties.c:3
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Определения param.c:12
Определения DayZGame.c:64
ErrorExSeverity
Определения EnDebug.c:62
void Error(string err)
Messagebox with error message.
Определения 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.
TypeID EventType
Определения EnWidgets.c:55