Skip to content

Commit

Permalink
fixes #1421 - improved error template loading (#1422)
Browse files Browse the repository at this point in the history
  • Loading branch information
amorton authored Sep 13, 2024
1 parent 5cf8626 commit 65c424d
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/main/java/io/stargate/sgv2/jsonapi/exception/ErrorConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@
import com.google.common.annotations.VisibleForTesting;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -268,13 +265,9 @@ private static ErrorConfig readFromYamlResource(String path) throws IOException
if (resourceURL == null) {
throw new FileNotFoundException("ErrorConfig Resource not found: " + path);
}
URI resourceURI;
try {
resourceURI = resourceURL.toURI();
} catch (URISyntaxException e) {
throw new IOException("ErrorConfig Resource " + path + " has Invalid URI: " + resourceURL, e);
try (var stream = resourceURL.openStream()) {
return readFromYamlString(new String(stream.readAllBytes(), StandardCharsets.UTF_8));
}
return readFromYamlString(Files.readString(Paths.get(resourceURI)));
}

/**
Expand Down

0 comments on commit 65c424d

Please sign in to comment.