REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 12-Oct-2010 Edit History  

REBOL 3 Functions: cause-error

cause-error  err-type  err-id  args

Causes an immediate error throw with the provided information.


err-type [word!]

err-id [word!]



Editor note: Description is a stub.

cause-error constructs and immediately throws an error!.

Editor note: Link to concept of error types?

Editor note: Argument description is a stub.

The err-type argument controls the general type of error to construct, valid values are the words of the system/catalog/errors object. The err-id argument selects a specific error type within the err-type class of errors. The args argument is used to pass error-specific values

Editor note: Description of error IDs is a stub.

All information about the currently available error types can be found in system/catalog/errors:

>> words-of system/catalog/errors
== [Throw Note Syntax Script Math Access Command resv700 User Internal]

The specific errors within a given class can be inspected similarly:

>> ? system/catalog/errors/math        
SYSTEM/CATALOG/ERRORS/MATH is an object of value: 
   code            integer!  400 
   type            string!   "math error" 
   zero-divide     string!   "attempt to divide by zero" 
   overflow        string!   "math or number overflow" 
   positive        string!   "positive number required"

All words except for code and type within an error type are possible specific errors. Their associated value is part of the error message that will displayed to the user if the error remains unhandled.

Some errors take arguments:

>> ? system/catalog/errors/script/no-value   
SYSTEM/CATALOG/ERRORS/SCRIPT/NO-VALUE is a block of value: [:arg1 "has no value"]

As an example, this no-value error which takes a single argument can be caused as follows:

>> cause-error 'script 'no-value 'Foo  
** script error: Foo has no value

Similarly, the two-argument no-arg error can be caused as follows:

>> cause-error 'script 'no-arg [Foo bar] 
** script error: Foo is missing its bar argument

  TOC < Back Next > - WIP Wiki Feedback Admin