REBOL 3 Docs | Guide | Concepts | Functions | Datatypes | Errors |
TOC < Back Next > | Updated: 6-Feb-2009 Edit History |
The error object shown above has the structure:
make object! [ code: 400 type: 'math id: 'zero-divide arg1: none arg2: none arg3: none near: [100 / 0] where: none ]
Where the fields are:
code | The error code number. These are obsolete and should not be used. |
type | The type field identifies the error category. It is always a word datatype of syntax, script, math, access, user, and internal. |
id | The id field is the name for the error as a word. It identifies the specific error that occurred within the error category. |
arg1 | This field holds the first argument to the error message. For instance, it may include the datatype of the value that caused the error. |
arg2 | This field holds the second argument to the error message. |
arg3 | This field holds the third argument to the error message. |
near | The near field is a code fragment that shows where the error occurred. |
where | The where field is reserved. |
You can write code that checks any of the error object fields. In this example, the error is printed only when the error id indicates a divide by zero error:
error: disarm try [1 / 0]
if error/id = 'zero-divide [
print {It is a Divide by Zero error}
]
It is a Divide by Zero error
The error id word also provides the error block that will be printed by the interpreter. For example:
error: disarm try [print zap]
probe get error/id
[:arg1 "has no value"]
This block is defined by the system/errors object.
TOC < Back Next > | REBOL.com - WIP Wiki | Feedback Admin |