Spec-Zone.ru › ColdFusion

cfthrow

Throws a developer-specified exception, which can be caught with a cfcatch tag that has any of the following type attribute options: type = "custom_type" type = "Application" type = "Any"

<cfthrow>

throw(message="");

  • CF4+
  • Lucee
  • BL 1.0.0+
  • See Also: cftry cfcatch cfrethrow cferror cfabort

    Attribute Reference

    type string
    Default: Custom

    Do not enter another predefined type; types are not generated by CFML applications. If you specify Application, you need not specify a type for cfcatch.
    Values:
    • Custom
    • Application
    • Database
    • Template
    • Security
    • Object
    • MissingInclude
    • Expression
    • Lock
    • SearchEngine

    message string

    Message that describes exception event.

    detail string

    Description of the event. CFML appends error position to description; server uses this parameter if an error is not caught by your code.

    errorcode string

    A custom error code that you supply.

    extendedinfo string

    A custom error code that you supply.

    object any

    Requires the value of the cfobject tag name attribute. Throws a Java exception from a CFML tag. This attribute is mutually exclusive with all other attributes of this tag.

    Compatibility

    ColdFusion:

    Version 4+ CF9+ throw added to cfscript.

    BoxLang:

    Version 1.0.0+ <bx:throw> in BoxLang

    Examples
    Sample code using the cfthrow tag

    Script Example: Try, Throw, Catch, Finally!

    Throw and Finally requires CF 9+ in cfscript

    try {
        throw(message="Oops", detail="xyz"); //CF9+
    } catch (any e) {
        writeOutput("Error: " & e.message);
    } finally { //CF9+
        writeOutput("I run even if no error");
    }

    Expected Result: Error: OopsI run even if no error

    © 2012–present Foundeo, Inc. and the CFDocs contributors.
    Licensed under the MIT License.
    ColdFusion is a trademark of Adobe Systems Incorporated.
    https://cfdocs.org/cfthrow

    Spec-Zone.ru

    Настройки Оффлайн Что нового Помощь О нас
    Spec-Zone .ru
    спецификации, руководства, описания, API