CFLib.org – Common Function Library Project

Throw([Type] [, Message] [, Detail] [, ErrorCode] [, ExtendedInfo] [, Object])

Last updated October 15, 2002
Download UDF

author

Raymond Camden                                    Raymond Camden

Version: 1 | Requires: ColdFusion MX | Library: CFMLLib

 
Rated 2 time(s). Average Rating: 3.5

Description:
Mimics the CFTHROW tag.

Return Values:
Does not return a value.

Example:

<cfscript>
x = 1;
try {
    if(x lt 9) throw("BadValue","X is less than 9","X is less than 9 and this is bad because....",9900);
    } catch("BadValue" e) {
        dump(e);
    } catch("Any" e) {
        // you won't see this
        writeOutput("Unknown error");
    }
</cfscript>

Parameters:

Name Description Required
Type Type for exception. No
Message Message for exception. No
Detail Detail for exception. No
ErrorCode Error code for exception. No
ExtendedInfo Extended Information for exception. No
Object Object to throw. No

Full UDF Source:

<!---
Mimics the CFTHROW tag.

@param Type      Type for exception. (Optional)
@param Message      Message for exception. (Optional)
@param Detail      Detail for exception. (Optional)
@param ErrorCode      Error code for exception. (Optional)
@param ExtendedInfo      Extended Information for exception. (Optional)
@param Object      Object to throw. (Optional)
@return Does not return a value.
@author Raymond Camden (ray@camdenfamily.com)
@version 1, October 15, 2002
--->

<cffunction name="throw" output="false" returnType="void" hint="CFML Throw wrapper">
    <cfargument name="type" type="string" required="false" default="Application" hint="Type for Exception">
    <cfargument name="message" type="string" required="false" default="" hint="Message for Exception">
    <cfargument name="detail" type="string" required="false" default="" hint="Detail for Exception">
    <cfargument name="errorCode" type="string" required="false" default="" hint="Error Code for Exception">
    <cfargument name="extendedInfo" type="string" required="false" default="" hint="Extended Info for Exception">
    <cfargument name="object" type="any" hint="Object for Exception">
    
    <cfif not isDefined("object")>
        <cfthrow type="#type#" message="#message#" detail="#detail#" errorCode="#errorCode#" extendedInfo="#extendedInfo#">
    <cfelse>
        <cfthrow object="#object#">
    </cfif>
    
</cffunction>

Search CFLib.org


Latest Additions

John Bartlett John Bartlett added
browserDetect
4 day(s) ago

Rob Brooks-Bilson Rob Brooks-Bilson added
listCompare
7 day(s) ago

Stephen Withington Stephen Withington added
formToNameValueP...
15 day(s) ago

anthony petruzzi anthony petruzzi added
parseExcel
20 day(s) ago

Pablo Varando Pablo Varando added
returnRandomHEXC...
21 day(s) ago

Top Rated

Nathan Dintenfass                                 QueryStringChang...
Rated 5.0, 10 time(s)

Stephen Withington formToNameValueP...
Rated 5.0, 5 time(s)

Gyrus                                             HTMLSafe
Rated 5.0, 4 time(s)

Shlomy Gantz                                      viewCSS
Rated 5.0, 4 time(s)

Michael Sharman generateRandomKe...
Rated 5.0, 3 time(s)

Created by Raymond Camden / Design by Justin Johnson