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
1 parent
72fba53
commit 16b5c81
Showing
4 changed files
with
46 additions
and
49 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
29 changes: 29 additions & 0 deletions
29
dropwizard-core/src/main/java/io/dropwizard/setup/ExceptionMapperBinder.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,29 @@ | ||
package io.dropwizard.setup; | ||
|
||
import io.dropwizard.jersey.errors.EarlyEofExceptionMapper; | ||
import io.dropwizard.jersey.errors.LoggingExceptionMapper; | ||
import io.dropwizard.jersey.jackson.JsonProcessingExceptionMapper; | ||
import io.dropwizard.jersey.validation.JerseyViolationExceptionMapper; | ||
import org.glassfish.hk2.utilities.binding.AbstractBinder; | ||
|
||
import javax.ws.rs.ext.ExceptionMapper; | ||
|
||
public class ExceptionMapperBinder extends AbstractBinder { | ||
private boolean showDetails; | ||
|
||
public ExceptionMapperBinder(boolean showDetails) { | ||
this.showDetails = showDetails; | ||
} | ||
|
||
@Override | ||
protected void configure() { | ||
bind(new LoggingExceptionMapper<Throwable>() {}).to(ExceptionMapper.class); | ||
bind(new JerseyViolationExceptionMapper()).to(ExceptionMapper.class); | ||
bind(new JsonProcessingExceptionMapper(isShowDetails())).to(ExceptionMapper.class); | ||
bind(new EarlyEofExceptionMapper()).to(ExceptionMapper.class); | ||
} | ||
|
||
public boolean isShowDetails() { | ||
return showDetails; | ||
} | ||
} |
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