From: DervishD <zsh@dervishd.net>
To: Peter Stephenson <pws@csr.com>
Cc: zsh-workers@sunsite.dk
Subject: Re: Exception handling and "trap" vs. TRAPNAL()
Date: Tue, 4 Oct 2005 19:46:04 +0200 [thread overview]
Message-ID: <20051004174604.GA21210@DervishD> (raw)
In-Reply-To: <EXCHANGE03sdEmM3sw800001ff8@exchange03.csr.com>
Hi Peter :)
* Peter Stephenson <pws@csr.com> dixit:
> DervishD wrote:
> > Just one note: why should be always blocks needed at all if you
> > can use this kind of solutions? As long as you don't cause ZERR to be
> > raised in "common_error()", this solution is much better because you
> > can fine tune (using the "trap" builtin) when do you want to do
> > common handling and when you don't. The only difference I can see is
> > that code in an always block is executed in the current environment
> > and code in "common_error()" is not.
> TRAP_RETURN triggers on any non-zero status, while an "always" block
> is used to stop actual errors which would usually cause everything in
> sight(*) to abort. If you're really concerned only with non-zero status
> and don't care about errors there's every reason to go with something
> like TRAP_RETURN.
But you can check for those kind of errors like this:
( #whatever would have caused an abortive-error )
OK, you must run them in a subshell, but the fact is that this is
doable. But I see, an always block here is far more readable and easy
to use (apart from being more optimal if the 'abortive-error' can
happen in a loop).
OTOH, code like this is very annoying when trapping ZERR:
# If the file doesn't exist, this will raise ZERR
# We probably will want ZERR raised if "do_something" fails,
# but certainly not if the test fails. We must use "if"...
[[ -r "$filename" ]] && do_something
Thanks for the explanation :)
Raúl Núñez de Arenas Coronado
--
Linux Registered User 88736 | http://www.dervishd.net
http://www.pleyades.net & http://www.gotesdelluna.net
It's my PC and I'll cry if I want to...
next prev parent reply other threads:[~2005-10-04 17:45 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20050929200741.GA1156@DervishD>
[not found] ` <20050930124130.45eb0463.pws@csr.com>
[not found] ` <20051001153756.GA12183@DervishD>
2005-10-01 18:38 ` Bart Schaefer
2005-10-01 19:10 ` Peter Stephenson
2005-10-01 20:41 ` DervishD
2005-10-01 22:44 ` Bart Schaefer
2005-10-02 8:06 ` DervishD
2005-10-01 20:28 ` DervishD
2005-10-02 4:40 ` Bart Schaefer
2005-10-02 8:13 ` DervishD
2005-10-02 19:09 ` Peter Stephenson
2005-10-02 19:55 ` Bart Schaefer
2005-10-02 23:00 ` DervishD
2005-10-03 1:37 ` Bart Schaefer
2005-10-03 8:57 ` Peter Stephenson
2005-10-03 14:51 ` Bart Schaefer
2005-10-03 15:10 ` Peter Stephenson
2005-10-03 16:50 ` Bart Schaefer
2005-10-03 9:01 ` DervishD
2005-10-03 16:21 ` Bart Schaefer
2005-10-03 17:59 ` DervishD
2005-10-04 16:31 ` Bart Schaefer
2005-10-04 17:29 ` DervishD
2005-10-04 17:34 ` Peter Stephenson
2005-10-04 17:46 ` DervishD [this message]
2005-10-01 8:01 DervishD
-- strict thread matches above, loose matches on Subject: below --
2005-10-01 7:45 DervishD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20051004174604.GA21210@DervishD \
--to=zsh@dervishd.net \
--cc=pws@csr.com \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).