Difference between revisions of "FSO Error Handling"
From FreeSpace Wiki
(Created page with "== Freespace2 Open Error Handling == {{note | Needs more details! }} This is meant to assist coders in figuring out how errors in FSO should be handled. === General === There…") |
(→General) |
||
Line 34: | Line 34: | ||
|- | |- | ||
| WarningEx( LOCATION, printf-formatted-message-needs-\n ); || No || | | WarningEx( LOCATION, printf-formatted-message-needs-\n ); || No || | ||
− | * | + | * Same as warning, except it will only trigger if the command line param "-extra_warn" is set |
|- | |- | ||
| Error( LOCATION, printf-formatted-message-needs-\n ); || Yes || | | Error( LOCATION, printf-formatted-message-needs-\n ); || Yes || | ||
Line 55: | Line 55: | ||
|- | |- | ||
| VerifyEx( ??? ); || Yes || | | VerifyEx( ??? ); || Yes || | ||
− | * | + | * Same as Verify, except it will only trigger if the command line param "-extra_warn" is set |
|- | |- | ||
| Int3(); || No || | | Int3(); || No || | ||
Line 62: | Line 62: | ||
* On other platforms I believe it acts like an Error | * On other platforms I believe it acts like an Error | ||
|} | |} | ||
− | |||
=== LUA Scripting === | === LUA Scripting === |
Revision as of 00:29, 21 May 2014
Contents
Freespace2 Open Error Handling
Note: Needs more details!
This is meant to assist coders in figuring out how errors in FSO should be handled.
General
There are several macros defined for error handling (see globalincs/pstypes.h).
One of the 1st concepts to understand is that some errors in trigger in DEBUG builds, others occur in both DEBUG and RELEASE.
Most of these can be used anywhere within the FSO codebase.
Name | In Release? | Description |
---|---|---|
mprintf(( printf-formatted-message-needs-\n )); | No |
Warning: Dynamically allocates memory (SCP_string) so don't use it inside memory management functions
|
nprintf(( TYPE, printf-formatted-message-needs-\n )); | No |
|
Warning( LOCATION, printf-formatted-message-needs-\n ); | No |
|
WarningEx( LOCATION, printf-formatted-message-needs-\n ); | No |
|
Error( LOCATION, printf-formatted-message-needs-\n ); | Yes |
|
Assert( statement ); | No |
|
Assertion( statement, printf-formatted-message-needs-\n ); | No |
|
Verify( ??? ); | Yes |
|
VerifyEx( ??? ); | Yes |
|
Int3(); | No |
|
LUA Scripting
While all the FSO error handling can be used in LUA, it's preferred to use the following where possible.
In parse/lua.cpp.
Name | In Release? | Description |
---|---|---|
LuaError( LuaObject, printf-formatted-message ); | ? |
|
ade_set_error( LuaObject, return-value-type, return-value ); | ? |
|
Table Parsing
tbc (I think there's some extra error handling options in here)
C++ Exceptions
Exceptions are relatively rare in FSO (see pilotcode for one exception (hardy-har-har)), I don't believe there's any formal exceptional handling scheme.