ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


functions:error

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
functions:error [2016/05/07 15:32] – [LimitError] korshunfunctions:error [2017/06/12 15:42] (current) – removed korshun
Line 1: Line 1:
-====== Error notification ====== 
- 
-Various functions can be used incorrectly. When this happens, you can put a print statement into the function. But will that print statement log to the server console in multiplayer? Will you not forget to use PrintBold instead of Print if the error happens with a non-player activator? What if you want to be able to turn error messages off? And finally, how should ACSUtils notify you about errors? 
- 
-To solve all these problems, ACSUtils provides a standardized error handling mechanism. Errors are triggered through a set of functions that pass them to your project's custom error handler (see [[..namedscripts|Named scripts]]). 
- 
-<code> 
-#define ACSUTILS_ERROR_HANDLER myproject_errorhandler 
-#include "acsutils.acs" 
- 
-script myproject_errorhandler (int type, int message) 
-{ 
- Log(s:"error: ", s:message); // Log to server console. 
- printbold(s:"error: ", s:message); // Print to all players. 
-} 
-</code> 
- 
-The error handler can do whatever it wants with the messages: it can show them only to the administrator, it can suppress messages if a cvar is set, or it can try to show them to everyone. 
- 
-The error handler also receives the type of the error. There are the following error types: 
- 
-  * ''ACSERROR_PROGRAM'' -- a programming error in scripts, this should be triggered when a function is used incorrectly. 
-  * ''ACSERROR_MAPPING'' -- a mapping error, this should be triggered when, for example, a needed actor is not present on the map. 
-  * ''ACSERROR_LIMIT'' -- a static limit has been reached, and should be increased. For example, ''HudPushState()'' will trigger this error when you try to save too many states. 
- 
-===== Error reporting functions ===== 
- 
-To report errors, use one of the following functions, corresponding to each of the error types: 
- 
-==== ProgramError ==== 
-''void ProgramError(str message)'' 
- 
-Triggers an ''ACSERROR_PROGRAM'' with the given message. 
- 
-==== MappingError ==== 
-''void MappingError(str message)'' 
- 
-Triggers an ''ACSERROR_MAPPING'' with the given message. 
- 
-==== LimitError ==== 
-''void LimitError(str message)'' 
- 
-Triggers an ''ACSERROR_LIMIT'' with the given message. 
- 
- 
- 
  
functions/error.1462635154.txt.gz · Last modified: by korshun