Created
July 3, 2018 10:10
-
-
Save Prashant1293/78eb08a2e927db2d62fcf53b10f23cef to your computer and use it in GitHub Desktop.
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
@Singleton | |
public class ErrorHandler extends DefaultHttpErrorHandler { | |
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); | |
@Inject | |
public ErrorHandler(Config configuration, Environment environment, | |
OptionalSourceMapper sourceMapper, Provider<Router> routes) { | |
super(configuration, environment, sourceMapper, routes); | |
} | |
@Override | |
protected CompletionStage<Result> onNotFound(Http.RequestHeader request, String message) { | |
String errorResponse = "The requested resource does not exist."; | |
JsonNode jsonNode = OBJECT_MAPPER.valueToTree(errorResponse); | |
return CompletableFuture.completedFuture(Results.notFound(jsonNode)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment