Spec-Zone.ru › ColdFusion

throw

Throws a developer-specified exception, which can be caught with a catch block.

throw([message] [, type] [, detail] [, errorcode] [, extendedinfo] [, object]) → returns numeric

  • CF9+
  • Lucee
  • BL 1.0.0+
  • Argument Reference

    message string

    Message that describes exception event.

    type string
    Default: Custom

    * A custom type * Application 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

    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

    Additional custom error data 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.

    Examples
    Sample code invoking the throw function

    Throw a custom exception

    Use the throw function to throw a custom application exception.

    <cfscript>
    throw(type="MyCustomError", message="A custom error has been thrown!");
    </cfscript>

    Throw a custom http response exception

    Use the throw function to throw a custom exception when the http response is invalid.

    if (!isJSON(httpResponse.fileContent)) {
    	throw(type="InvalidHTTPResponse",message="The http response was not valid JSON");
    }

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

    Spec-Zone.ru

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