Find error cause from config exception and print as best we can
@@ -15,9 +15,11 @@ import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import java.net.URI;
import java.util.NoSuchElementException;
+import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
+import javax.json.JsonException;
/**
* The main entry point for the application. This just starts up the application
@@ -58,13 +60,29 @@ public class Launcher {
System.out.println("Config validation issue: " + violation.getPropertyPath() + " " + violation.getMessage());
}
System.exit(1);
+ } catch (com.quorum.tessera.config.ConfigException ex) {
+ Throwable cause = resolveRooCause(ex);
+
+ if (JsonException.class.isInstance(cause)) {
+ System.err.println("Invalid json error is " + cause.getMessage());
+ } else {
+ System.err.println(Objects.toString(cause));
+ }
+
+ System.exit(3);
} catch (Throwable ex) {
+
Optional.ofNullable(ex.getMessage()).ifPresent(System.err::println);
System.exit(2);
}
}
-
+ static Throwable resolveRooCause(Throwable ex) {
+ if (Objects.nonNull(ex.getCause())) {
+ return resolveRooCause(ex.getCause());
+ }
+ return ex;
+ }
private static void runWebServer(final URI serverUri, ServerConfig serverConfig) throws Exception {
