Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added configurable stack trace returns in 500 errors
- Loading branch information
Showing
5 changed files
with
52 additions
and
7 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
25 changes: 25 additions & 0 deletions
25
fcrepo-http-commons/src/main/java/org/fcrepo/exceptionhandlers/WildcardExceptionMapper.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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
package org.fcrepo.exceptionhandlers; | ||
|
||
import static com.google.common.base.Throwables.getStackTraceAsString; | ||
import static javax.ws.rs.core.Response.serverError; | ||
|
||
import javax.ws.rs.core.Response; | ||
import javax.ws.rs.ext.ExceptionMapper; | ||
|
||
public class WildcardExceptionMapper implements ExceptionMapper<Exception> { | ||
|
||
Boolean showStackTrace; | ||
|
||
@Override | ||
public Response toResponse(Exception e) { | ||
|
||
return serverError().entity( | ||
showStackTrace ? getStackTraceAsString(e) : null).build(); | ||
} | ||
|
||
public void setShowStackTrace(Boolean showStackTrace) { | ||
this.showStackTrace = showStackTrace; | ||
} | ||
|
||
} |
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
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
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