Skip to content

Commit 69dedb5

Browse files
committed
addendum - fix webhdfs
1 parent 0312916 commit 69dedb5

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/resources/ExceptionHandler.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,29 @@ public Response toResponse(Exception e) {
109109
s = Response.Status.BAD_REQUEST;
110110
} else if (e instanceof IllegalArgumentException) {
111111
s = Response.Status.BAD_REQUEST;
112+
} else if (e != null && e.getCause() != null) {
113+
if (e.getCause() instanceof SecurityException) {
114+
s = Response.Status.FORBIDDEN;
115+
e = (Exception) e.getCause();
116+
} else if (e.getCause() instanceof AuthorizationException) {
117+
s = Response.Status.FORBIDDEN;
118+
e = (Exception) e.getCause();
119+
} else if (e.getCause() instanceof FileNotFoundException) {
120+
s = Response.Status.NOT_FOUND;
121+
e = (Exception) e.getCause();
122+
} else if (e.getCause() instanceof IOException) {
123+
s = Response.Status.FORBIDDEN;
124+
e = (Exception) e.getCause();
125+
} else if (e.getCause() instanceof UnsupportedOperationException) {
126+
s = Response.Status.BAD_REQUEST;
127+
e = (Exception) e.getCause();
128+
} else if (e.getCause() instanceof IllegalArgumentException) {
129+
s = Response.Status.BAD_REQUEST;
130+
e = (Exception) e.getCause();
131+
} else {
132+
LOG.warn("INTERNAL_SERVER_ERROR", e);
133+
s = Response.Status.INTERNAL_SERVER_ERROR;
134+
}
112135
} else {
113136
LOG.warn("INTERNAL_SERVER_ERROR", e);
114137
s = Response.Status.INTERNAL_SERVER_ERROR;

0 commit comments

Comments
 (0)