diff --git a/server/src/main/java/com/hedera/block/server/Server.java b/server/src/main/java/com/hedera/block/server/Server.java index cd9e07c9..ee11cd39 100644 --- a/server/src/main/java/com/hedera/block/server/Server.java +++ b/server/src/main/java/com/hedera/block/server/Server.java @@ -16,6 +16,7 @@ package com.hedera.block.server; +import com.hedera.block.server.exception.UnhandledIOException; import edu.umd.cs.findbugs.annotations.NonNull; import java.io.IOException; @@ -38,12 +39,13 @@ public static void main(final String[] args) { @NonNull final BlockNodeAppInjectionComponent daggerComponent = DaggerBlockNodeAppInjectionComponent.create(); - @NonNull final BlockNodeApp server = daggerComponent.getBlockNodeApp(); + @NonNull final BlockNodeApp blockNodeApp = daggerComponent.getBlockNodeApp(); try { - server.startServer(); + blockNodeApp.startServer(); } catch (IOException e) { - throw new RuntimeException(e); + LOGGER.log((System.Logger.Level.ERROR), "Failed to start server", e); + throw new UnhandledIOException(e); } } } diff --git a/server/src/main/java/com/hedera/block/server/exception/UnhandledIOException.java b/server/src/main/java/com/hedera/block/server/exception/UnhandledIOException.java new file mode 100644 index 00000000..b1e5daee --- /dev/null +++ b/server/src/main/java/com/hedera/block/server/exception/UnhandledIOException.java @@ -0,0 +1,22 @@ +package com.hedera.block.server.exception; + +import java.io.Serial; + +/** + * UnhandledIOException is a RuntimeException that wraps an IOException. + * This can be used to rethrow checked IOExceptions as unchecked exceptions. + */ +public class UnhandledIOException extends RuntimeException { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * Constructs a new UnhandledIOException with the specified cause. + * + * @param cause the underlying IOException that caused this exception + */ + public UnhandledIOException(final Throwable cause) { + super(cause); + } +}