An Error object encapsulates information about errors -- these
may have happened due to scripting errors, or to a communications failure or a
failure due to a system call etc.
An Error has various properties -- the three most
important of these are:
class |
Integer | the class of error |
code |
Integer | the code of an error -- this has meaning within the particular error class |
text |
String | a textual description for an error |
All error handling within Carapace script is done using the following three functions:
try |
show the intention to catch errors generated by the supplied expression |
catch |
catch a given class of errors |
throw |
throw an error - so it can be caught elsewhere |
This page deals with the Error object which is thrown around.
For a description of the various error classes and their codes, click here
The create function is used to create an Error
of a given class etc.
(create Error 1 2 "ooops!")
creates an error of class 1, code 2 with a
(not very helpful) textual description of ooops!.
Other optional arguments can follow the text -- these can be of type Integer, Real or further Strings. The Error object concatenates these into the error text.
| property name | property type | description |
|---|---|---|
class |
Integer | the class of error |
code |
Integer | the code of an error -- this has meaning within the particular error class |
text |
String | a textual description for an error |
file |
String | name of file where the error occurred |
line |
Integer | the line number of the file where the error occurred |
positionInLine |
Integer | the position within the line where the error occurred |
showLocation |
Object | flag to determine whether the string
method will contain the error location information -- this is a property
shared by all instances of an Error
object
|
| method name | description |
|---|---|
clear |
clear out information within the Error object |
set |
set the class, code and text for the Error |
locate |
set the file and line location for the Error |
exists |
test if an error exists ie. if the class is non-zero |
string |
convert the Error to a string representation |
clear
Clear out information within the Error object.
Arguments: none
Return type: the empty List ()
set
Set the class, code and text for the Error. Other optional
arguments can follow the text -- these can be of type Integer,
Real or further Strings.
The Error object concatenates these into the error text.
Arguments:
| class | Integer |
| code | Integer |
| text | String |
| ... | Integer,
Real, or
String |
Return type: the empty List ()
locate
Set the file and line location for the Error.
Arguments:
| file | String |
| line | Integer |
Return type: List
exists
Test if an error exists ie. if the class is non-zero.
Arguments: none
Return type: List
string
Convert the Error to a string representation.
Arguments: none
Return type: String
| Contents | Index | Current topic: objects | Related links: built-in objects |