Ticket #62710: catch.tcl

File catch.tcl, 548 bytes (added by jmroot (Joshua Root), 4 years ago)
Line 
1package require macports
2package require macports_util
3
4proc test1 {} {
5    try {
6        error foo
7    } catch {{*} eCode eMessage} {
8        error "There was an error: $eMessage"
9    }
10}
11
12proc test2 {} {
13    try {
14        error foo
15    } catch {{*} eCode eMessage} {
16        return -code error "There was an error: $eMessage"
17    }
18}
19
20if {[catch {test1} result]} {
21    puts "test1 errored: $result"
22} else {
23    puts "no error for test1"
24}
25
26if {[catch {test2} result]} {
27    puts "test2 errored: $result"
28} else {
29    puts "no error for test2"
30}