<commit_before>package org.sagebionetworks.bridge.play.http;

import models.StatusMessage;
import play.http.HttpErrorHandler;
import play.libs.F.Promise;
import play.libs.Json;
import play.mvc.Http.RequestHeader;
import play.mvc.Result;
import play.mvc.Results;

public class BridgeErrorHandler implements HttpErrorHandler {

    @Override
    public Promise<Result> onClientError(RequestHeader request, int statusCode, String message) {
        return getResult(message);
    }

    @Override
    public Promise<Result> onServerError(RequestHeader request, Throwable exception) {
        return getResult(exception.getMessage());
    }

    private Promise<Result> getResult(final String message) {
        return Promise.<Result>pure(Results.badRequest(Json.toJson(new StatusMessage(message))));
    }
}<commit_msg>Render bad request as html page<commit_after>package org.sagebionetworks.bridge.play.http;

import models.StatusMessage;
import play.http.HttpErrorHandler;
import play.libs.F.Promise;
import play.libs.Json;
import play.mvc.Http.RequestHeader;
import play.mvc.Result;
import play.mvc.Results;

public class BridgeErrorHandler implements HttpErrorHandler {

    @Override
    public Promise<Result> onClientError(RequestHeader request, int statusCode, String message) {
        return getResult(request, message);
    }

    @Override
    public Promise<Result> onServerError(RequestHeader request, Throwable exception) {
        return getResult(request, exception.getMessage());
    }

    private Promise<Result> getResult(final RequestHeader request, final String message) {
        return Promise.<Result>pure(Results.badRequest(
                views.html.defaultpages.badRequest.render(request.method(), request.uri(), 
                        Json.toJson(new StatusMessage(message)).asText())));
    }
}
{'fraction_non_alphanumeric': 0.0963855421686747, 'fraction_numerical': 0.0, 'mean_word_length': 4.342105263157895, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7058937', 'n_tokens_mistral': 503, 'n_tokens_neox': 488, 'n_words': 111}