LogoLogo
Changelog
18.2
18.2
  • Welcome
    • Welcome to Airkit 👋
    • Quickstart
    • Flight School & Certification
  • Tutorials
    • Building A Contact Form
      • Building the Web UI
      • Building the Database
      • Finalizing the App
      • Connecting to Salesforce (Advanced)
      • Appendix
      • FAQ
    • Styles, Themes, and Templates
      • Changing the header
      • Changing the Theme
      • Using a custom font
      • Using Animations
      • FAQ
      • Appendix
    • Multi-Page Form
      • Creating the App Object in AirData
      • Building the Form’s UI
      • Creating the Data Flow to insert data
      • Connecting the Data Flow to the UI
      • Previewing and Publishing the app
    • Scheduling and Follow-Up App
      • Collecting Contact Information
      • Creating Appointment Times
      • Saving Appointment Information
      • Scheduling Appointment Reminder
      • Automating Proactive Follow-Up
      • Finalizing all Journey Steps
      • Appendix
      • FAQ
    • Custom Integrations (Petfinder App)
      • Querying the Petfinder API
      • Displaying Petfinder Data
      • Appendix
  • Concepts
    • Journeys
      • Linking to Journeys
    • Actors
      • Conversations with Actors
  • Console
    • Console
      • Apps
      • Activity
      • App Health
      • Datastores
      • Integrations
      • Resources
      • API
      • Settings
  • Studio
    • Studio
    • Builder Bar
      • Journey Builder
      • Triggers Builder
      • Web Flows Builder
      • Chat Bots Builder
      • Voice Bots Builder
      • Connections Builder
      • Notifications Builder
      • AirData Builder
      • Media Library
      • Theme Builder
      • Schedules Builder
      • Settings
    • App Preview
    • Action Builder
    • Web Flows
    • Data Flows
    • Variable Tree
    • Events
      • Session Started Events
      • Trigger Events
      • Control Events
      • Session Events
      • Activity Group Events
  • Working with Data
    • Working with Data Overview
    • Variable Namespaces
    • Standard Journey Data
    • AirData
      • AirData App Objects
      • Datastores
      • Identity Objects
      • Place Objects
      • Schedule Objects
    • Airscript Quickstart
      • Working with Dates and Times
      • Working with Missing Values
      • Working with URLs and Base64
    • Pull Values from Lists and Objects
      • Path Expressions
      • Query Expressions
  • Integration Guides
    • Integrations Overview
    • First Party Integration Guides
      • Creating A Salesforce Lead
      • Creating a Zendesk Ticket
      • Creating SFTP Credentials
      • Swagger Schema Validation
    • Custom Integration Guides
      • OAuth 2.0
      • API Token
      • HTTP Basic Auth
      • Custom Token
      • SFTP
      • Examples: Twitter and Giphy
    • App APIs
      • Building an App API
    • Subscriptions (Web Hooks)
  • SMS
    • Overview
    • SMS Notification Basics
    • Chat Bot Basics
    • Texting Journey Links
    • Data from Inbound Calls/SMS
    • Connecting Twilio Numbers
  • Emails
    • Overview
    • Email Notification Basics
    • Sending Emails by Data Operation
    • Connecting Email Addresses
  • Building Apps
    • Forms
      • Displaying Controls Dynamically
      • Repeating Elements
      • Prefilling Forms
      • Validation of User Data
      • Capture Secure User Data
      • Progress Bars
      • Dropdown Menus
      • Electronic Signatures
    • Voice Bots
      • Voice Bot Basics
    • Calendars
      • Customizing Schedule Availability
      • Using Availability Schedules
      • Rescheduling Deflected Calls
      • Integrating to External Calendars
    • Maps and Addresses
      • Maps
      • Addresses
      • User's Current Location
      • Address Search Map Binding
    • Payments
      • Creating a Stripe Integration
    • Timers and Reminders
      • Setting Timers
      • Setting up Periodic Tasks
    • PDFs
      • Creating a PDF
      • Working with Existing PDFs
      • Adding Assets to PDF
    • Assets and Media
      • Using the File Upload Web Control
      • Working with Files and Media
      • Assets and Data Operations
      • Sending Assets to Remote Servers
    • Publishing
      • Publishing Your Application
      • Editing an Application
      • Importing/Exporting Apps
      • Profiles and Deployment Settings
      • Tying Variables to Deployments
    • Advanced
      • Custom Controls
      • Creating Custom Functions
    • Accessibility
      • Accessibility in Airkit
  • Authentication
    • SAML Authentication
    • OAuth 2.0 - Google
    • OAuth 2.0 - Okta
    • OAuth 2.0 - Auth0
    • Azure AD B2C
    • Authentication Apps and Secure Apps
  • Embeds
    • Overview
    • SDKs
      • SDK Quickstart
      • SDK Authentication
      • Passing Data
      • Configuration
      • Configuration Examples
    • Airkit Lightning Component (Salesforce)
    • Embeds
      • Embedding Apps on Websites
      • AirClient Configurable Properties
      • Creating Secure Embeds
  • Styling
    • Themes and Control Variants
    • Importing and Exporting Themes
    • Working with Custom Fonts
    • Creating an App Header
    • Page Layouts
    • Animations
  • Analytics
    • Analytics Overview
    • App Events to Splunk
    • App Events to AWS S3 Buckets
    • Audit Logs to AWS S3 Buckets
    • View Data in Activity Explorer
    • Snowflake Analytics Schema
    • Power BI
    • Heap and GTM Integrations
      • Setting up Analytics with GTM
      • Setting up Analytics with Heap
  • Administration
    • Custom Domains
    • SAML SSO for an Organization
    • User Roles
      • Working with Custom Roles
    • Adding Users to Airkit
    • Airkit Organizations
    • Environments
      • Environmental Governance
    • Managing the Application Lifecycle
    • Getting Application Metadata
  • Error Management
    • Logging Custom Event Errors
    • Integrating Error Notifications to Slack
  • Security And Compliance
    • App Security FAQ
    • IP Ranges
    • Encrypting Data
    • SSL Auth
    • TCPA
    • Cookie Policies
    • Supported Browsers
    • Realms
  • Airscript Expressions
    • Text Functions
      • CAPITALIZE
      • CONCAT
      • ISSTRING
      • LOWERCASE
      • PADSTRING
      • REPLACE
      • REPT
      • SPLIT
      • STRING_COMPARE
      • STRING_FIND
      • STRIP
      • SUBSTITUTE
      • SUBSTRING
      • TITLECASE
      • TRIM
      • UPPERCASE
    • DateTime Functions
      • ADD_TO_DATE
      • ADD_TO_DATETIME
      • DATE
      • DATETIME
      • DATETIME_DELTA
      • DATETIME_FROM_FORMAT
      • DATETIME_FROM_TIMESTAMP
      • DATE_DELTA
      • DATE_FROM_DATETIME
      • DATE_FROM_FORMAT
      • DAY
      • DAYS
      • FORMAT_DATE
      • FORMAT_DATETIME
      • FORMAT_TIME
      • HOUR
      • ISO_WEEK
      • MINUTE
      • MONTH
      • NOW
      • SECOND
      • SUBTRACT_FROM_DATE
      • SUBTRACT_FROM_DATETIME
      • TIME
      • TIMESTAMP_FROM_DATETIME
      • TIME_DELTA
      • TIME_FROM_DATETIME
      • TIME_FROM_FORMAT
      • TODAY
      • UPDATE_DATE
      • UPDATE_DATETIME
      • UPDATE_DAY
      • UPDATE_HOUR
      • UPDATE_MILLISECOND
      • UPDATE_MINUTE
      • UPDATE_MONTH
      • UPDATE_SECOND
      • UPDATE_TIME
      • UPDATE_TIMEZONE
      • UPDATE_YEAR
      • WEEK
      • WEEKDAY
      • YEAR
    • List Functions
      • CONTAINS
      • FIRST
      • FLAT
      • JOIN
      • LAST
      • LENGTH
      • REMOVE_EMPTY
      • SHUFFLE
    • Object Functions
      • KEYS
      • VALUES
      • MERGE_OBJECTS
    • Math Functions
      • ABS
      • ACOS
      • ACOSH
      • ACOT
      • ACOTH
      • ASIN
      • ASINH
      • ATAN
      • ATAN2
      • ATANH
      • CEILING
      • COMBIN
      • COMBINA
      • COS
      • COSH
      • COT
      • COTH
      • CSC
      • CSCH
      • DEGREES
      • EVEN
      • EXP
      • FACT
      • FACTDOUBLE
      • FLOOR
      • GCD
      • ISEVEN
      • ISNUMBER
      • ISODD
      • LATLNGDISTANCE
      • LCM
      • LN
      • LOG
      • MAX
      • MIN
      • MROUND
      • MULTINOMIAL
      • ODD
      • PI
      • POWER
      • PRODUCT
      • RADIANS
      • RANDOM
      • RANGE
      • ROUND
      • ROUNDDOWN
      • ROUNDUP
      • SEC
      • SECH
      • SIGN
      • SIN
      • SINH
      • SQRT
      • SQRTPI
      • SUM
      • SUMSQ
      • TAN
      • TANH
      • TRUNC
    • Conditional Functions
      • EQUAL
      • IF
      • ISEMPTY
      • ISNOTEMPTY
      • NOT
    • Currency Functions
      • CURRENCY
      • FORMAT_CURRENCY
      • PARSE_CURRENCY
    • Phone Functions
      • FORMAT_PHONE
      • ISPHONE
      • PARSE_PHONE
    • Email Functions
      • ISEMAIL
    • Number Formatting Functions
      • ARABIC
      • FORMAT_NUMBER
      • PARSE_NUMBER
      • ROMAN
    • Data Type Functions
      • FROM_JSON
      • TO_JSON
      • TYPEOF
    • Asset Functions
      • ASSET_SIZE
      • ASSET_STATE
      • ASSET_THUMBNAIL_URL
      • ASSET_TO_URI
      • ASSET_TYPE
      • URI_TO_ASSET
    • Encoding Functions
      • BASE
      • BASE64_DECODE
      • BASE64_ENCODE
      • HMAC_MD5
      • HMAC_SHA1
      • HMAC_SHA256
      • MD5
      • SHA1
      • SHA256
      • URL_DECODE
      • URL_ENCODE
      • UUID
      • VALUE_OF
    • Error Handling Functions
      • THROW
      • TRY
    • Arithmetic Operators
      • Addition (+)
      • Subtraction (-)
      • Multiplication (*)
      • Division (/)
      • Remainder (%)
    • Comparison Operators
      • Equality (=)
      • Inequality (<>, !=)
      • Ordering (<, <=, > , >=)
    • Advanced Expressions
      • User Defined Functions
      • LET...IN
  • Web Controls
    • Web Controls Overview
      • Common Style Properties of Web Controls
    • Button
    • Checkbox
    • Simple Checkbox List
    • Container
    • Container List
    • Credit Card
    • Currency Input
    • Date Input
    • Date Picker
    • Dropdown List
    • Email Input
    • Embedded External Content (Container)
    • Fieldset Container
    • File Upload
    • Hyperlink
    • Image
    • Label
    • Map
    • Number Input
    • Payment Request Button
    • Phone Input
    • Place Search Input
    • Progress Bar
    • Radio Button
    • Simple Radio List
    • Scheduler
    • Secure String Input
    • Selectable Container
    • Signature Input
    • Text Area
    • Text Input
    • Time Input
    • Web Flow
    • Web Page
    • QR Code
  • Voice and Chat Controls
    • Decision Menu
    • Forward Call
    • Secure Touchtone Capture
    • Text Response Capture
    • Touchtone Capture
  • Data Operations
    • Data Operation Overview
    • AirData Request
      • DELETE
      • PUT
      • INSERT
      • PATCH
      • QUERY
      • DEPRECATED_QUERY
    • Calendar Search
    • Create File
    • Delete Assets
    • Download Encoded Asset
    • Early Return
    • Fetch Asset Details
    • Fill PDF Form
    • Google
    • HTML to PDF
    • HTTP Request
      • Using an API With Paging
    • JWT Generation
    • Merge PDF
    • Run Data Flow
    • Run Event in Journey
    • Salesforce
    • Secure Value Retrieval
    • Send Email
    • SFTP
    • Start Journey
    • Swagger Schema Validation
    • Transform
    • Wait
    • XML to JSON
    • Zendesk
    • ZIP File
  • Actions
    • Analytics Identify
    • Analytics Send Event
    • Close Modal
    • Condition
    • End Session
    • Extend Session Expiration Time
    • Go to Next Journey Step
    • Initialize Actor
    • Log Custom Event
    • Metric: Count
    • Metric: Field
    • Metric: Start Timer
    • Metric: Statistic
    • Metric: Stop Timer
    • Navigate To Web Flow
    • Navigate to Web Page
    • Open Modal
    • Run Data Flow
    • Run Data Flow Repeatedly
    • Run Embedded Outgoing Event
    • Run Event
    • Send Email
    • Send SMS
    • Set Authentication
    • Set Identifier
  • Variable Data Types
    • Data Types Overview
    • Any (JSON)
    • Asset
      • Detailed Asset
    • Boolean
    • Currency
    • Date
    • DateTime
    • Email
    • List
    • Null
    • Number
    • Phone
    • Text
    • Time
    • Custom Data Types
  • Integrations
    • Genesys Widget Integration
    • Zendesk Integration
    • Salesforce Integration
    • Plaid Integration
    • Twilio Integration
    • Stripe Integration
    • Shopify Integration
    • Airtable Integration
    • Google Integration
    • SFTP Integration
  • Product Versions
    • CXR Overview
    • CXR Upgrades and Migrations
  • Quickstart Sample API
    • The Transportation Products API
    • GET products
    • GET product-by-id
Powered by GitBook
On this page

Was this helpful?

  1. Airscript Expressions
  2. Error Handling Functions

THROW

The function THROW throws an error, halting evaluation and providing identifying error details based on the given input.

[block:callout] { "type": "info", "body": "The THROW function is unique among Airscript functions in that it halts evaluation, preventing it from returning any output. Input given to the THROW function, describing the error identifier, the error message, and, optionally, any metadata pertaining to the error will be incorporated into the error details as well as the error message." } [/block]

Declaration

THROW(error_identifier, error_message, error_metadata) -> input_value

Parameters

error_identifier (required, type: string) The error identifier.

error_message (required, type: string) The error message.

error_metadata (optional, type: object) Metadata pertaining to the error.

Return Values

This function halts evaluation, preventing it from returning any values.

Examples

When called correctly, the THROW function will throw an error:

THROW(
    "Unexpected response status", 
    "Found wrong response status."
) -> ERROR

The error thrown by a correctly-called THROW function, however, will differ from an error thrown by an incorrectly-called THROW function, in that the given input will be used to generate the error details. For instance, in the case of the above expression, the error details will appear as follows. Note that the value of metadata.identifier matches the error_identifier given in the expression above; likewise, metadata.message matches the given error_message:

{
  "airkitErrorType": "ApplicationError",
  "sourceProject": XXX,
  "name": "ApplicationError",
  "identifier": "error.application.user-defined-error",
  "metadata": {
    "identifier": "Unexpected response status",
    "message": "Found wrong response status.",
    "metadata": {},
    "url": XXX,
    "statusText": "",
    "statusCode": 400
  },
  "httpStatus": 400
}

The THROW function can optionally accept metadata in the form of an object. This object can consist of any number of key-value pairs:

THROW(
  "Unexpected response status",
  "Found wrong response status.",
  {
    expected_status: FALSE,
    error: TRUE
  }
) -> ERROR

The error details of the above expression will appear as follows. Note that the value of metadata.metadata matches the value of error_metadata given in the expression above:

{
  "airkitErrorType": "ApplicationError",
  "sourceProject": XXX,
  "name": "ApplicationError",
  "identifier": "error.application.user-defined-error",
  "metadata": {
    "identifier": "Unexpected response status",
    "message": "Found wrong response status.",
    "metadata": {
      "expected_status": false,
      "error": true
    },
    "url": XXX,
    "statusText": "",
    "statusCode": 400
  },
  "httpStatus": 400
}

Airscript expressions can be used to generate more specific values for identifiers, messages, or metadata. For instance, say the following expression have access to the variable found_status, which is defined as follows:

found_status = "Pending"

This variable can be used to generate an error message that displays the found status in addition to flagging the status as unexpected:

THROW(
  "Unexpected response status",
  "Status found: {{found_status}}"
) -> ERROR

The error details of the above expression will appear as follows. Note how the value of metadata.message appears:

{
  "airkitErrorType": "ApplicationError",
  "sourceProject": XXX,
  "name": "ApplicationError",
  "identifier": "error.application.user-defined-error",
  "metadata": {
    "identifier": "Unexpected response status",
    "message": "Status found: \"Pending\"",
    "metadata": {},
    "url": XXX,
    "statusText": "",
    "statusCode": 400
  },
  "httpStatus": 400
}

Discussion

As a more concrete example, the THROW function can be used to thrown an error if some date variable (input_date) indicates a date before the present day:

IF(
  input_date
    < DATE_FROM_DATETIME(NOW()),
  THROW(
    "Date is too old!",
    "Date is {{
      FORMAT_DATE(
        input_date,
        "YYYY/DD/MM"
      )
    }}"
  )
)
PreviousError Handling FunctionsNextTRY

Last updated 1 year ago

Was this helpful?

Unlike most Airscript functions, THROW is not used for data manipulation. It is instead meant to aid in the app-testing process by making errors more legible. Errors thrown via the THROW function cannot be sent as App Notifiers. (If you need to send a notifier in response to a custom error, use a .) Otherwise, errors thrown by the THROW function be logged everywhere automatically-generated errors are. For instance, when , errors thrown by the THROW function will be flagged as errors in the Event Log Viewer.

The THROW function is commonly used in tandem with conditionals incorporated directly into a Journey. For instance, it might be part of a branching Action, or used in as input within an function to perform validation.

Such validation expressions will usually be lengthy, and we recommend incorporating them into when possible.

Throwing custom errors can also be an important component of , depending on the use case.

Custom Event Error
Previewing
Condition
IF
User Defined Functions
App APIs