Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <ygaed2k8zfs.fsf@akutech.de>
Deutsch   English   Français   Italiano  
<ygaed2k8zfs.fsf@akutech.de>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: news.eternal-september.org!eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!2.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: Ralf Fassel <ralfixx@gmx.de>
Newsgroups: comp.lang.tcl
Subject: Re: try... query
Date: Fri, 06 Dec 2024 18:59:51 +0100
Lines: 64
Message-ID: <ygaed2k8zfs.fsf@akutech.de>
References: <viut96$2bm0b$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net 6vuGtCkKA86MfKu3qM6N9wRECIya53L1Anab+5GpioTwJu5bQ=
Cancel-Lock: sha1:XLnpgNNJWLe9NPtykgvvhkY0U8E= sha1:o7j3YrA9hWGRsJYtbY2ZgnehSlc= sha256:Y8Xm066nmedvaJkPIxB3KlLFNW6PhGjOVMluP6t7dts=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

* Alan Grunwald <nospam.nurdglaw@gmail.com>
| proc allocateResources {} {
|     set obj1 [Some_mechanism]
|     try {
|         set obj2 [Some_other_mechanism]
|         try {
|             do_various_other_stuff
|         } on error {message errorDict} {
|             $obj2 destroy
|             return                                          \
|                 -code error                                 \
|                 -errorcode [dict get $errorDict -errorcode] \
|                 -errorinfo [dict get $errorDict -errorinfo] \
|                 $message
|         }

As Harald pointed out, 'finally' is the way to go here (even if the
"if exist" is clunky :-).

I just wanted to point out that you could use the errorDict directly, as in

  try {
    ...
  } on error {msg opts} {
    ...
    return -options $opts $msg
  }

instead of extracting errorinfo and errorcode manually, and if I use
that form, I get the expected behaviour:

    proc foo {} {
        try {
            puts "level 1"
            try {
                puts "level 2"
                error "err level 2"
            } on error {msg opts} {
                puts "error in level 2"
                return -options $opts $msg
            }
        } on error {msg opts} {
            puts "error in level 1"
            return -options $opts $msg
        }
    }
    
    % catch foo
    level 1
    level 2
    error in level 2
    error in level 1
    1
    
    % set errorInfo
    err level 2
        while executing
    "error "err level 2""
        (procedure "foo" line 6)
        invoked from within
    "foo"

HTH
R'