Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2009-04-19
09:21 • Closed ticket [2142989fff]: add examples to the catch man page plus 6 othe... artifact: 577a5c00c0 user: sf-robot
2009-04-05
00:09 • Pending ticket [2142989fff]. artifact: 6bc1c145ec user: dkf
2008-10-03
05:07 • Ticket [2142989fff]: 8 changes artifact: 98a365780c user: msofer
04:43 • Open ticket [2142989fff]. artifact: 80e0d75f3d user: yurivict
02:46 • Pending ticket [2142989fff]. artifact: 30cf1a10ef user: msofer
2008-10-02
19:32 • New ticket [2142989fff]. artifact: 6f625f3f7d user: nobody

add examples to the [catch] man page

Closed / Works For Me2142989fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 18 years ago
Descriptionplain2008-10-02 19:32:29
I use tcl-8.5.4.

In the following code 'catch' returns 1 indicating an error but '::errorInfo' isn't set, producing 'no such variable' message.


--- testcase ---
proc c {} {}
proc main {} {
  if {[catch { return [c] }]} {
    puts "ERROR: *$::errorInfo* *************"
  }
}
main

--- output ----
can't read "::errorInfo": no such variable
    while executing
"puts "ERROR: *$::errorInfo* *************""
msoferplain2008-10-03 02:46:25
Wrong diagnostic: [catc] is not returning 1 (error) but 2 (return); no error, no errorInfo ...
 mig@oli:~$ tclsh
 % proc c {} {}
 % catch {return [c]}
 2
yurivictplain2008-10-03 04:43:38
Makes sense: 'catch' has 5 possible return values (0..4).

Then I suggest you add another example of basic 'catch' usage in EXAMPLES section of catch(n) demonstrating all 5 return values.
Otherwise people look at the example (if {[catch...]} {...exit...}) and get misled by it's simplicity.
msoferplain2008-10-03 05:07:28
Catch can return a lot of other codes - essentially, any 32-bit integer value:
 % catch {return -code 1234 -level 0}
 1234
If you have a suggestion on how to improve the man page and examples, please add it here.
dkfplain2009-04-05 00:09:01
Might also want to try the [try] command in 8.6
sf-robotplain2009-04-19 09:21:06
allow_comments - 1

This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).
Log in (anonymous is fine) to add a comment.