From ca6307ce27978dfac391b46db243992e9d201503 Mon Sep 17 00:00:00 2001 From: Julian Psotta Date: Mon, 25 Nov 2024 16:11:31 +0100 Subject: [PATCH] chore(sonar): Introduce a custom RuntimeException ORSGraphFileManagerExceptionException.java. java:S112. --- .../ORSGraphFileManagerExceptionException.java | 7 +++++++ .../extensions/manage/GraphInfo.java | 17 ++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 ors-engine/src/main/java/org/heigit/ors/exceptions/ORSGraphFileManagerExceptionException.java diff --git a/ors-engine/src/main/java/org/heigit/ors/exceptions/ORSGraphFileManagerExceptionException.java b/ors-engine/src/main/java/org/heigit/ors/exceptions/ORSGraphFileManagerExceptionException.java new file mode 100644 index 0000000000..2fc9d1fc30 --- /dev/null +++ b/ors-engine/src/main/java/org/heigit/ors/exceptions/ORSGraphFileManagerExceptionException.java @@ -0,0 +1,7 @@ +package org.heigit.ors.exceptions; + +public class ORSGraphFileManagerExceptionException extends RuntimeException { + public ORSGraphFileManagerExceptionException(String message, Throwable cause) { + super(message, cause); + } +} \ No newline at end of file diff --git a/ors-engine/src/main/java/org/heigit/ors/routing/graphhopper/extensions/manage/GraphInfo.java b/ors-engine/src/main/java/org/heigit/ors/routing/graphhopper/extensions/manage/GraphInfo.java index 09d45ea399..febd5edfeb 100644 --- a/ors-engine/src/main/java/org/heigit/ors/routing/graphhopper/extensions/manage/GraphInfo.java +++ b/ors-engine/src/main/java/org/heigit/ors/routing/graphhopper/extensions/manage/GraphInfo.java @@ -1,31 +1,38 @@ package org.heigit.ors.routing.graphhopper.extensions.manage; +import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import lombok.experimental.Accessors; +import org.apache.log4j.Logger; +import org.heigit.ors.exceptions.ORSGraphFileManagerExceptionException; import java.io.File; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; -@Accessors(chain = true) -@Getter -@Setter @NoArgsConstructor +@AllArgsConstructor +@Setter +@Accessors(chain = true) public class GraphInfo { - private URI remoteUri = null; + private URI remoteUri; + @Getter private File localDirectory = null; + Logger logger = Logger.getLogger(GraphInfo.class.getName()); + @Getter private PersistedGraphInfo persistedGraphInfo; public GraphInfo withRemoteUrl(URL url) { try { this.remoteUri = url.toURI(); } catch (URISyntaxException e) { - throw new RuntimeException(e); + logger.error("Error while parsing remote URL %s with message %s".formatted(url, e.getMessage())); + throw new ORSGraphFileManagerExceptionException("Error while parsing remote URL %s.".formatted(url), e); } return this; }