Skip to content

Commit

Permalink
refactor: PathFinder 내 null값 예외 처리 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
the9kim committed Sep 11, 2023
1 parent 6cb1b9a commit c3ecfe8
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions tomcat/src/main/java/org/apache/coyote/http11/util/PathFinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,17 @@ public class PathFinder {

private static final String RESOURCE_ROOT_DIRECTORY_PATH = "static";

public static Path findPath(String resourceName) throws URISyntaxException {
final URL resource =
PathFinder.class.getClassLoader().getResource(RESOURCE_ROOT_DIRECTORY_PATH + resourceName);
return Paths.get(resource.toURI());
public static Path findPath(String resourceName) {
try {
URL resource =
PathFinder.class.getClassLoader().getResource(RESOURCE_ROOT_DIRECTORY_PATH + resourceName);

if (resource == null) {
throw new IllegalArgumentException("Resource Not Found: " + resourceName);
}
return Paths.get(resource.toURI());
} catch (URISyntaxException e) {
throw new RuntimeException("URI Syntax Exception : " + resourceName);
}
}
}

0 comments on commit c3ecfe8

Please sign in to comment.