Mailinglist Archive: yast-devel (81 mails)

< Previous Next >
[yast-devel] About catching exceptions
  • From: Klaus Kaempf <kkaempf@xxxxxxx>
  • Date: Thu, 22 Apr 2010 11:36:58 +0200
  • Message-id: <20100422093658.GA20795@xxxxxxxxxxxxx>
Hi,

when calling functions known to raise exceptions, its always good
practice to enclose calls with begin ... rescue ... end and catch
exceptions locally.

Catching exceptions should cover known problems (i.e. missing
permissions) as well as generic problems.

Example:


WRONG:

call_function_which_might_raise


NOT ENOUGH:

begin
call_function_which_might_raise
rescue KnownException => e
handle_known_exception e
end

GOOD:

begin
call_function_which_might_raise
rescue KnownException => e
handle_known_exception e
rescue Exception => e
handle_generic_exception e
end


The 'wrong' and 'not enough' cases validate bug reports.

Klaus
---
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG N├╝rnberg)

--
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-devel+help@xxxxxxxxxxxx

< Previous Next >
Follow Ups