Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2013-02-08
16:24 • Closed ticket [3603804fff]: misleading example in documentation of try plu... artifact: 3b5dc03d67 user: dkf
09:23
[3603804]: Improve example to actually be capable of throwing the trapped errors check-in: 2ac1c24629 user: dkf tags: trunk
08:51 • New ticket [3603804fff] misleading example in documentation of try. artifact: 094fe8242a user: uring

misleading example in documentation of [try]

Closed / Fixed3603804fffffffffffffffffffffffffffffffffCreated 14 years agoUpdated 14 years ago
Descriptionplain2013-02-08 08:51:15
the documentation of the try command contains the following example:

try {
    set f [open /some/file/name]
} trap {POSIX EISDIR} {} {
    puts "failed to open /some/file/name: it's a directory"
} trap {POSIX ENOENT} {} {
    puts "failed to open /some/file/name: it doesn't exist"
}

this (slightly) misleading, since (on unix) it is allowed to open a directory for reading, i.e. you will never get
the message "failed to open /some/file/name: it's a directory".

a simple fix would be to open for writing:  "try { set f [open /some/file/name w] ......"
dkfplain2013-02-08 16:24:54
allow_comments - 1

Fair enough; fixed on trunk.
Log in (anonymous is fine) to add a comment.