app: when loading config, handle returned errors
authorMarcus Fritzsch <marcus_fritzsch@mentor.com>
Tue, 1 Aug 2017 14:05:29 +0000 (16:05 +0200)
committerMarcus Fritzsch <marcus_fritzsch@mentor.com>
Tue, 8 Aug 2017 15:24:00 +0000 (17:24 +0200)
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
src/app.cpp

index 353557e..461ac35 100644 (file)
@@ -113,19 +113,27 @@ App::App(wl::display *d)
      display{d},
      controller{},
      outputs(),
-     layouts(),  // load_layout("../layout.json").unwrap()),
-     surface2layer(load_layer_ids("../ids.json").unwrap()) {
-   // layouts(load_layout("../layout.json").unwrap()) {
+     layouts(),
+     surface2layer() {
    assert(g_app == nullptr);
    g_app = this;
 
-   try {
+   {
+      auto l = load_layer_ids("../ids.json");
+      if (l.is_ok()) {
+         this->surface2layer = l.unwrap();
+      } else {
+         logerror("%s", l.err().value());
+      }
+   }
+
+   {
       auto l = load_layout("../layout.json");
-      if (l.is_err()) {
-         logerror("Coult not load layout configuration: %s", l.err().value());
+      if (l.is_ok()) {
+         this->layouts = l.unwrap();
+      } else {
+         logerror("%s", l.err().value());
       }
-   } catch (std::exception &e) {
-      logerror("Coult not load layout configuration: %s", e.what());
    }
 }