This is an automated email from the ASF dual-hosted git repository.

bchapuis pushed a commit to branch 745-daylight
in repository https://gitbox.apache.org/repos/asf/incubator-baremaps.git

commit 11c808a94c3092bd2632f33754949028823d4945
Author: Bertil Chapuis <[email protected]>
AuthorDate: Mon Sep 18 21:37:26 2023 +0200

    Remove try catch
---
 .../main/java/org/apache/baremaps/cli/map/Dev.java | 145 ++++++++++-----------
 1 file changed, 69 insertions(+), 76 deletions(-)

diff --git a/baremaps-cli/src/main/java/org/apache/baremaps/cli/map/Dev.java 
b/baremaps-cli/src/main/java/org/apache/baremaps/cli/map/Dev.java
index 4c572b1f..a3a06e2a 100644
--- a/baremaps-cli/src/main/java/org/apache/baremaps/cli/map/Dev.java
+++ b/baremaps-cli/src/main/java/org/apache/baremaps/cli/map/Dev.java
@@ -66,81 +66,74 @@ public class Dev implements Callable<Integer> {
 
   @Override
   public Integer call() throws Exception {
-    try {
-      var configReader = new ConfigReader();
-      var objectMapper = objectMapper();
-      var tileset = 
objectMapper.readValue(configReader.read(this.tilesetPath), Tileset.class);
-      var datasource = 
PostgresUtils.createDataSourceFromObject(tileset.getDatabase());
-
-      var tileStoreType = new TypeLiteral<Supplier<TileStore>>() {
-      };
-      var tileStoreSupplier = (Supplier<TileStore>) () -> {
-        try {
-          var config = configReader.read(this.tilesetPath);
-          var tilesetObject =
-                  objectMapper.readValue(config, Tileset.class);
-          return new PostgresTileStore(datasource, tilesetObject);
-        } catch (IOException e) {
-          e.printStackTrace();
-          throw new RuntimeException(e);
-        }
-      };
-
-      var styleSupplierType = new TypeLiteral<Supplier<Style>>() {
-      };
-      var styleSupplier = (Supplier<Style>) () -> {
-        try {
-          var config = configReader.read(stylePath);
-          return objectMapper.readValue(config, Style.class);
-        } catch (IOException e) {
-          throw new RuntimeException(e);
-        }
-      };
-
-      var tileJSONSupplierType = new TypeLiteral<Supplier<Tileset>>() {
-      };
-      var tileJSONSupplier = (Supplier<Tileset>) () -> {
-        try {
-          var config = configReader.read(tilesetPath);
-          return objectMapper.readValue(config, Tileset.class);
-        } catch (IOException e) {
-          throw new RuntimeException(e);
-        }
-      };
-
-      var application = new ResourceConfig()
-              .register(CorsFilter.class)
-              .register(ChangeResource.class)
-              .register(TileResource.class)
-              .register(StyleResource.class)
-              .register(TilesetResource.class)
-              .register(ChangeResource.class)
-              .register(ClassPathResource.class)
-              .register(newContextResolver(objectMapper))
-              .register(new AbstractBinder() {
-                @Override
-                protected void configure() {
-                  bind("assets").to(String.class).named("directory");
-                  bind("viewer.html").to(String.class).named("index");
-                  bind(tilesetPath).to(Path.class).named("tileset");
-                  bind(stylePath).to(Path.class).named("style");
-                  bind(tileStoreSupplier).to(tileStoreType);
-                  bind(styleSupplier).to(styleSupplierType);
-                  bind(tileJSONSupplier).to(tileJSONSupplierType);
-                }
-              });
-
-      var httpService = new 
HttpJerseyRouterBuilder().buildBlockingStreaming(application);
-      var serverContext = 
HttpServers.forPort(port).listenBlockingStreamingAndAwait(httpService);
-
-      logger.info("Listening on {}", serverContext.listenAddress());
-      serverContext.awaitShutdown();
-
-      return 0;
-    } catch (Exception e) {
-      e.printStackTrace();
-      return 1;
-
-    }
+    var configReader = new ConfigReader();
+    var objectMapper = objectMapper();
+    var tileset = objectMapper.readValue(configReader.read(this.tilesetPath), 
Tileset.class);
+    var datasource = 
PostgresUtils.createDataSourceFromObject(tileset.getDatabase());
+
+    var tileStoreType = new TypeLiteral<Supplier<TileStore>>() {
+    };
+    var tileStoreSupplier = (Supplier<TileStore>) () -> {
+      try {
+        var config = configReader.read(this.tilesetPath);
+        var tilesetObject =
+                objectMapper.readValue(config, Tileset.class);
+        return new PostgresTileStore(datasource, tilesetObject);
+      } catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+    };
+
+    var styleSupplierType = new TypeLiteral<Supplier<Style>>() {
+    };
+    var styleSupplier = (Supplier<Style>) () -> {
+      try {
+        var config = configReader.read(stylePath);
+        return objectMapper.readValue(config, Style.class);
+      } catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+    };
+
+    var tileJSONSupplierType = new TypeLiteral<Supplier<Tileset>>() {
+    };
+    var tileJSONSupplier = (Supplier<Tileset>) () -> {
+      try {
+        var config = configReader.read(tilesetPath);
+        return objectMapper.readValue(config, Tileset.class);
+      } catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+    };
+
+    var application = new ResourceConfig()
+            .register(CorsFilter.class)
+            .register(ChangeResource.class)
+            .register(TileResource.class)
+            .register(StyleResource.class)
+            .register(TilesetResource.class)
+            .register(ChangeResource.class)
+            .register(ClassPathResource.class)
+            .register(newContextResolver(objectMapper))
+            .register(new AbstractBinder() {
+              @Override
+              protected void configure() {
+                bind("assets").to(String.class).named("directory");
+                bind("viewer.html").to(String.class).named("index");
+                bind(tilesetPath).to(Path.class).named("tileset");
+                bind(stylePath).to(Path.class).named("style");
+                bind(tileStoreSupplier).to(tileStoreType);
+                bind(styleSupplier).to(styleSupplierType);
+                bind(tileJSONSupplier).to(tileJSONSupplierType);
+              }
+            });
+
+    var httpService = new 
HttpJerseyRouterBuilder().buildBlockingStreaming(application);
+    var serverContext = 
HttpServers.forPort(port).listenBlockingStreamingAndAwait(httpService);
+
+    logger.info("Listening on {}", serverContext.listenAddress());
+    serverContext.awaitShutdown();
+
+    return 0;
   }
 }

Reply via email to