Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Exception handling and "trap" vs. TRAPNAL()



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.

(*) for some values of "everything"

pws


This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com



Messages sorted by: Reverse Date, Date, Thread, Author