First page Back Continue Last page Overview Image

8.6 Control Structures – Errors

[329][348] try, throw, return -errorstack

proc read_hex_file {fname} {

set f [open $fname "r"]

set data {}

try {

while { [gets $f line] >= 0 } { append data [binary format H* $line] }

} trap {POSIX} {e} {

puts "POSIX-type error: $e"

} on error {em} {

error "Could not process file '$fname': $em"

} finally {

close $f

}

}