Hi.
I got a master script calling a subscript.
The subscript calls dtexec to execute a dts and then logs the result in a database. (sort of step level logging)
Since the error is handled, I need it to "fail" in order for the master script to log it's end result as well (that will be a batch level logging)
So what I do is this:
MASTER:
D:\Agoda\Application\powershell\scripts\Ps_Booking_Prestaging.ps1 $v_batchid $v_jobid $v_conn $v_to $v_from
if ($LASTEXITCODE -ne 0)
{
log-batchend $v_batchid "FAILED" $v_conn
exit
}
SUBSCRIPT:
#run task
$v_logid = log-taskstart $v_batchid $v_jobid $v_taskid $v_name $v_conn $v_to $v_from
$results = rundtsx $v_dtsxFile 0 $v_batchid $v_jobid $v_taskid $v_conn $v_to $v_from
if ($results -ne 0)
{
log-taskend $v_logid $v_batchid $v_jobid $v_taskid "FAILED" "909000002" $v_conn
throw "a runtime error has occured"
exit
}
I use throw to throw and error if it fails which should then be catched by MASTER.
I do have the throw error and the log table is properly updated with a "FAILED" status but at MASTER level I get nothing.
I've tried using if !($?) instead to no avail. It looks like throw command stops the sub script and the master script right there.
Anybody has an idea on how to handle that?
Thanks
Nico