Am Sonntag, 2. Juli 2006 20:53 schrieb Bud Beacham:
> I fixed this by enclosing RunQuery in a CATCH block. Now for another
> maximum stress test.
>
>
> #--------------------------------------------------------------------------
>----------------------- proc RunQuery {resultDir dataBase query} {
> set P [format "$::FW" "([lindex [info level 0] 0])"]
> #
> #
> set qryResult ""
> catch {
> sqlite dbCmd $dataBase
> dbCmd timeout 300
> set qryResult [dbCmd eval $query]
> set errorCode [dbCmd errorcode]
> dbCmd close
> Log $resultDir "$P ERROR: $errorCode"
> } catchResult
> if {$catchResult != ""} {
> Log $resultDir "$P CATCH: $catchResult"
> set qryResult TCR_FAIL
> }
> return $qryResult
> } ;# RunQuery
>
>
Huh? I'm pretty sure you should read the catch(n) manpage again. The code
above does not check for the "catch" result properly. This has to be done
like that:
if [ catch {
sqlite dbCmd $dataBase
dbCmd timeout 300
set qryResult [dbCmd eval $query]
set errorCode [dbCmd errorcode]
dbCmd close
Log $resultDir "$P ERROR: $errorCode"
} catchResult ] {
Log $resultDir "$P CATCH: $catchResult"
set qryResult TCR_FAIL
}
In addition, it's considered good style in Tcl *not* catching the error in the
innermost proc level, but just let them wind up until they can be really
interpreted or logged. So just throw away the whole "catch" block here and
check this in your QueryDataBase function. And if you really need to throw an
error, use "return -code error -errorcode ... MESSAGE", not just a string
like TCR_FAIL, which could come up as a valid evaluation result.
Just my 2 Cts
Jan
--
"I'm not a programmer, but I play one at Microsoft."