-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
12 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 7 additions & 9 deletions
16
plume-web-jersey/src/main/java/com/coreoz/plume/jersey/jee/ErrorServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,22 @@ | ||
package com.coreoz.plume.jersey.jee; | ||
|
||
import java.io.IOException; | ||
import java.io.PrintWriter; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import javax.servlet.ServletException; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import java.io.PrintWriter; | ||
|
||
@Slf4j | ||
public class ErrorServlet extends HttpServlet { | ||
|
||
private static final long serialVersionUID = 6186826368888103404L; | ||
|
||
@Override | ||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { | ||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) { | ||
try(PrintWriter printWriter = resp.getWriter()) { | ||
int errorCode = resp.getStatus(); | ||
String errorMessage = HttpStatus.getStatusText(errorCode); | ||
printWriter.println("Error " + errorCode + " : " + errorMessage); | ||
} | ||
} catch (Exception e) { | ||
logger.error("Error displaying error message for error code {}", resp.getStatus()); | ||
} | ||
} | ||
|
||
} |