Effect that halts execution after a dialog message event. You can use halt
within an on-empty
, on-catch
, or ordered-effects
block.
action (GetResultHalt) {
type (Search)
description (This will never succeed, and will always halt.)
collect {
}
output (Result) {
throws {
error (ErrorWhichHalts) {
on-catch {
halt {
dialog {
template ("Execution is halted because of the ErrorWhichHalts error.")
}
}
}
}
}
}
}
In the example below, a capsule checks to see if there is no data available and throws a NoData
checked error.
//if response is bad, throw NoData error
if (!response || response.failure || !response.globalairquality)
throw fail.checkedError('no air quality data', 'NoData')
The output of the GetAirQuality
action in that capsule catches this error and uses a noDataAirQuality
macro to provide a useful error using on-catch
and halt
:
action (GetAirQuality) {
description (Get the air quality for a location)
type (Search)
...
output (AirQuality) {
throws {
error (NoData) {
on-catch {
halt {
dialog {
macro(noDataAirQuality)
}
}
}
}
}
}
}
The actual definition of the macro (macro-def
) looks like this:
macro-def(noDataAirQuality){
content: template ("No air quality data available.")
}
Dialog associated with halt
effects will always have a Short
timeout value unless the short-timeout-on-halt-dialog
runtime flag is set to false
.