Throw()
Throws a developer-specified exception, which can be caught with a <cfcatch> tag
Throw( message=string, type=string, detail=string, errorcode=string, extendedInfo=string, object=any, cause=any );
Returns: void
| Argument | Description |
|---|---|
|
message
string,
optional
|
edit
Message that describes exception event. |
|
type
string,
optional
|
edit
|
|
detail
string,
optional
|
edit
Additional detail about the exception. Often used for more sensitive information, i.e. which you may choose not to display to end users |
|
errorcode
string,
optional
|
edit
A custom error code that you supply. |
|
extendedInfo
string,
optional
|
edit
Extended information about the exception. |
|
object
any,
optional
|
edit
Throws a Java exception from a CFML tag. This attribute is mutually exclusive with all other arguments of this function. |
|
cause
any,
optional
|
edit
The cause of the exception created with this tag. This can be a cfcatch block or a native java exception. |
Examples
edit // thrown as a statement example
try {
throw "thrown";
} catch (e){
dump(var=cfcatch, label="single argument keyword");
}
/* this won't work as expected, because thrown expects only a single
argument function in cfscript, only message will be populated
see https://luceeserver.atlassian.net/browse/LDEV-2832
*/
try {
throw message="thrown"
detail="deets"
errorCode="403"
type="Test";
} catch (e){
dump(var=cfcatch, label="additional arguments are ignored");
}
// use this syntax instead
try {
throw (message="thrown",
detail="deets",
errorCode="403",
type="Test");
} catch (e){
dump(var=cfcatch, label="script throw with arguments");
}
See also
- <cfthrow>
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)