On Mon, 09 Dec 2013 14:46:32 +0100 Lukas Ocilka <lukas.ocilka@suse.com> wrote:
On 25.10.2013 16:34, Josef Reidinger wrote:
Hi, I would like to announce, that new version of ruby bindings (3.1.2) is released. There is two changes:
1. Detect if there is invalid response type from client ( client call using component system, so only simple types are allowed ) - https://github.com/yast/yast-ruby-bindings/issues/81
2. Improved exception handling. Now if exception appear in client, then error message about internal error is shown to user. It using Report.Error so it works good in various cases ( TUI, autoyast, CLI ). After report it works as before, so client return nil and continue. Reason for this change is to reduce number of silent failures and encourage everyone to use exceptions in yast code.
Nice, I also suggest using an error pop-up dialog with additional details and print the backtrace there (if user clicks [Details]) the same way we do it on web.
Well, I am not enough experienced in yui and details. I welcome any pull requests :)
I think we need some rules for exceptions. My proposel is to use exceptions everywhere and every uncaught exception is bug. This behavior allows us to quickly see problem and do not have current silent failures.
Could you explain a bit further and/or provide some nice example how to use exceptions in Yast?
Initially it is when you translate from Ops and Builtins to native ruby, then you immediatelly can get exceptions with nil access. Otherwise I think it make sense to raise exception in models we use and catch it in UI and provide something useful to target user. Especially if problem is in inconsistent system or wrong provided data. like possible it was used in rails controllers begin s = Metadata.load_from(UI.url_field) ... catch InvalidUrl Popup.Error("Invalid URL in url field. Please check for typos") catch DataMissing Popup.Error("Cannot find anything at given URL. Please check for typos") catch InvalidMetadata Popup.Error("URL contains invalid metadata. Please contact owner of given URL") end
Yes, we need to define what is the correct use for exception, for instance I've seen using trow -> catch (raise -> rescue) used to exit from a deep multi-foreach loop, but that doesn't seem to be nice usage :)
No, that is in fact wrong usage :)
Opinions on for what to use exceptions in Yast?
I think we should not reinvent wheel and exception is quite well article covered topic ( and it is same in C++ or java or any other language with exceptions ). Like http://codebuild.blogspot.cz/2012/01/15-best-practices-about-exception.html http://javarevisited.blogspot.cz/2013/03/0-exception-handling-best-practices... http://code.google.com/p/solidbase/wiki/ExceptionHandlingGuideline ebook http://exceptionalruby.com/ (paid) Josef
Bye Lukas
-- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org