Improve error handling and reporting in the LED pattern parser
[led-pattern-ed] / src / led-program-dialog.vala
index 63e8eda..004d0ea 100644 (file)
@@ -150,9 +150,10 @@ class LedProgramDialog : Gtk.Dialog {
 
        void on_text_received (Gtk.Clipboard clipboard, string text) {
                var clip_pattern = new LedPatternRX51 ();
-               if (clip_pattern.parse (text)) {
+               try {
+                       clip_pattern.parse (text);
                        lpv.pattern.replace_with (clip_pattern);
-               } else {
+               } catch (LedPatternError e) {
                        Hildon.Banner.show_information (null, null, "Not a valid pattern");
                }
        }