MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1 | SYNOPSIS |
Zesstra | 7ea4a03 | 2019-11-26 20:11:40 +0100 | [diff] [blame] | 2 | void runtime_error( string err, string prg, string curobj, int line |
| 3 | , mixed culprit, int caught) |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 4 | |
| 5 | DESCRIPTION |
Zesstra | 7ea4a03 | 2019-11-26 20:11:40 +0100 | [diff] [blame] | 6 | This function has to announce a runtime error to the active |
| 7 | user. If the user has enough privileges, it might give him the |
| 8 | full error message together with the source line. Else it |
| 9 | should issue a decent message ("Your sensitive mind notices a |
| 10 | wrongness in the fabric of space"). |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 11 | |
Zesstra | 7ea4a03 | 2019-11-26 20:11:40 +0100 | [diff] [blame] | 12 | <err> is the error message, <prg> is the program executed (which |
| 13 | might be an inherited program), <curobj> is the current object at |
| 14 | the time of the error. <line> is the linenumber within the program. |
| 15 | |
| 16 | If the error is a normal runtime error, <culprit> is -1. Otherwise, |
| 17 | the error occurred during a heartbeat and <culprit> is the object which |
| 18 | heart_beat() function was executed. Also, in case of a heartbeat error, |
| 19 | the heartbeat for the <culprit> has been turned off. |
| 20 | |
| 21 | If the error is caught on a higher level, <caught> is non-zero; |
| 22 | otherwise it is 0. |
| 23 | |
| 24 | Note that any of the the objects or programs might be destructed, ie. |
| 25 | might be passed as 0. |
| 26 | |
| 27 | One common pitfall in the implementation of runtime_error() is |
| 28 | that runtime_error() itself could run out of evaluation ticks, |
| 29 | causing a runtime error itself. The workaround is to use |
| 30 | limited() like this: |
| 31 | |
| 32 | static void |
| 33 | handle_runtime_error ( string err, string prg, string curobj |
| 34 | , int line) |
| 35 | { ... the actual error handler ... } |
| 36 | |
| 37 | static void |
| 38 | call_runtime_error (string err, string prg, string curobj, int line) |
| 39 | { |
| 40 | limited(#'handle_runtime_error, ({ 200000 }), err, prg, curobj |
| 41 | , line); |
| 42 | } |
| 43 | |
| 44 | void |
| 45 | runtime_error (string err, string prg, string curobj, int line) |
| 46 | { |
| 47 | limited(#'call_runtime_error, ({ LIMIT_UNLIMITED }) |
| 48 | , err, prg, curobj, line); |
| 49 | } |
| 50 | |
| 51 | HISTORY |
| 52 | LDMud 3.2.9 added the <culprit> argument. |
| 53 | LDMud 3.2.12/3.3.705 added the <caught> argument. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 54 | |
| 55 | SEE ALSO |
Zesstra | 7ea4a03 | 2019-11-26 20:11:40 +0100 | [diff] [blame] | 56 | log_error(M), heart_beat_error(M), runtime_warning(M), |
| 57 | raise_error(E), expand_define(E) |