Created
July 3, 2018 09:08
-
-
Save Prashant1293/b938e73a38cc3edf85337243aaf762cd 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(Configuration 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