diff --git a/gui/api.tcl b/gui/api.tcl index f6f72457..cd2ed179 100644 --- a/gui/api.tcl +++ b/gui/api.tcl @@ -1480,8 +1480,13 @@ proc parseEventMessage { data len flags channel } { if { $eventtype == 4 } { ;# entered the runtime state if { $g_traffic_start_opt == 1 } { startTrafficScripts } if { $execMode == "batch" } { - global g_current_session - puts "disconnecting. Session id is $g_current_session" + global g_current_session g_abort_session + if {$g_abort_session} { + puts "Current session ($g_current_session) aborted. Disconnecting." + shutdownSession + } else { + puts "Session running. Session id is $g_current_session. Disconnecting." + } exit.real } } elseif { $eventtype == 6 } { ;# shutdown state diff --git a/gui/core.tcl b/gui/core.tcl index c1407d69..8ed9c90a 100644 --- a/gui/core.tcl +++ b/gui/core.tcl @@ -126,6 +126,7 @@ loadPluginsConf checkCommandLineAddressPort autoConnectPlugins +set g_abort_session 0 # # Initialization should be complete now, so let's start doing something... @@ -176,7 +177,7 @@ if {$execMode == "interactive"} { after 100 { loadCfg $cfg deployCfgAPI $sock - puts "waiting to enter RUNTIME state..." + puts "Waiting to enter RUNTIME state..." } global vwaitdummy vwait vwaitdummy diff --git a/gui/exceptions.tcl b/gui/exceptions.tcl index 5b61d5a3..22f3be2f 100644 --- a/gui/exceptions.tcl +++ b/gui/exceptions.tcl @@ -12,11 +12,21 @@ set g_cel_blink_state "off" # receive an exception into the g_exceptions array from an Exception Message proc receiveException { valuelist } { - global g_exceptions EXCEPTION_LEVELS + global g_exceptions EXCEPTION_LEVELS execMode set idx [expr {1 + [array size g_exceptions]}] array set g_exceptions [list $idx $valuelist] - # exceptions with level ERROR or FATAL will throw the CEL array set vals $valuelist + # print exception message on stdout if in batch mode + if { $execMode == "batch" } { + puts "\nFrom $vals(src): $vals(txt)" + + # Abort the session if a fatal exception is reported + if { $vals(level) <= [lsearch -exact $EXCEPTION_LEVELS "FATAL" ] } { + global g_current_session g_abort_session + set g_abort_session 1 + } + } + # exceptions with level ERROR or FATAL will throw the CEL if { $vals(level) <= [lsearch -exact $EXCEPTION_LEVELS "ERROR"] } { throwCEL false if { $vals(level) <= [lsearch -exact $EXCEPTION_LEVELS "FATAL" ] } {