Example usage for org.springframework.http HttpStatus getReasonPhrase

List of usage examples for org.springframework.http HttpStatus getReasonPhrase

Introduction

In this page you can find the example usage for org.springframework.http HttpStatus getReasonPhrase.

Prototype

public String getReasonPhrase() 

Source Link

Document

Return the reason phrase of this status code.

Usage

From source file:org.apereo.openlrs.model.error.XAPIErrorInfo.java

private void getDataFromHttpStatus(final HttpStatus status) {
    this.status = status.value();
    this.reason = status.getReasonPhrase();
}

From source file:com.github.tddts.jet.oauth.server.DefaultAuthHandler.java

@Override
public void process(AuthHandlerCallback callback, List<NameValuePair> params) {
    if (params.isEmpty()) {
        callback.returnMessage(responseText);
    } else {/*from w  w w .  j av a 2s.  c  o  m*/
        HttpStatus status = authService.processAuthorization(params);
        String message = status.is2xxSuccessful() ? successMessage : status.getReasonPhrase();
        callback.returnMessage(status.value(), message);
    }
}

From source file:com.ogaclejapan.dotapk.WebApiError.java

public WebApiError(HttpStatus status, String message, String code) {
    this.status = status.value();
    this.message = (message != null) ? message : status.getReasonPhrase();
    this.code = code;
}

From source file:app.api.swagger.SwaggerConfig.java

private ResponseMessage response(final HttpStatus status, final String ref) {
    return new ResponseMessage(status.value(), status.getReasonPhrase(), new ModelRef(ref));
}

From source file:com.orange.clara.tool.controllers.AbstractDefaultController.java

protected ResponseEntity<String> generateEntityFromStatus(HttpStatus httpStatus) {
    return ResponseEntity.status(httpStatus).body(httpStatus.value() + " " + httpStatus.getReasonPhrase());
}

From source file:com.tsguild.videogamewebapp.controller.ErrorController.java

public String customError(HttpServletRequest request, HttpServletRequest response, Model model) {
    Integer statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code");
    HttpStatus httpStatus = HttpStatus.valueOf((statusCode));

    Throwable throwable = (Throwable) request.getAttribute("javax.servlet.error.exception");
    String exceptionMessage = httpStatus.getReasonPhrase();

    String requestUri = (String) request.getAttribute("javax.servlet.error.request.uri");
    if (requestUri == null) {
        requestUri = "Unknown";
    }//from  w w  w  .  ja  v  a2 s  .  com

    String message = MessageFormat.format("{0} returned for {1}: {2}", statusCode, requestUri,
            exceptionMessage);

    model.addAttribute("errorMessage", message);
    return "customError";
}

From source file:edu.pitt.dbmi.ccd.anno.error.ErrorMessage.java

/**
 * Constructor//  w w w. j  a v a2s.  c om
 *
 * @param http http status
 * @param message error message
 * @param req http servlet request
 * @return ErrorMessage with current timestamp, status and error from
 * HttpStatus, message, and path from HttpServletRequest
 */
public ErrorMessage(HttpStatus http, String message, HttpServletRequest req) {
    this.timestamp = new Date();
    this.status = http.value();
    this.error = http.getReasonPhrase();
    this.message = message;
    this.path = req.getRequestURI();
}

From source file:net.maritimecloud.identityregistry.exception.McBasicRestException.java

public McBasicRestException(HttpStatus status, String errorMessage, String path) {
    this.status = status;
    this.errorMessage = errorMessage;
    this.path = path;
    this.timestamp = new Date().getTime();
    this.error = status.getReasonPhrase();
}

From source file:net.ljcomputing.core.controler.ErrorInfo.java

/**
 * Instantiates a new error info./*  w  w  w  . j a  v a  2 s.c  om*/
 *
 * @param timestamp the timestamp
 * @param status the status
 * @param path the path
 * @param exception the exception
 */
public ErrorInfo(String timestamp, HttpStatus status, String path, Exception exception) {
    this.timestamp = timestamp;
    this.status = Integer.valueOf(status.value()).toString();
    this.error = status.getReasonPhrase();
    this.path = path;

    if (exception instanceof ConstraintViolationException) {
        StringBuffer eb = new StringBuffer("The save failed validation as follows: ");
        for (ConstraintViolation<?> cv : ((ConstraintViolationException) exception).getConstraintViolations()) {
            eb.append(cv.getMessage() + ",");
        }
        eb.reverse().replace(0, 1, "").reverse();
        this.message = eb.toString();
    } else if (null != exception.getLocalizedMessage()) {
        this.message = exception.getLocalizedMessage();
    } else if (null != exception.getMessage()) {
        this.message = exception.getMessage();
    } else {
        this.message = "An error occured during processing: " + exception.toString();
    }
}

From source file:com.swcguild.capstoneproject.controller.ErrorController.java

@RequestMapping(value = "/error")
public String customError(HttpServletRequest request, HttpServletResponse response, Model model) {
    Integer statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code");
    HttpStatus httpStatus = HttpStatus.valueOf(statusCode);
    Throwable throwable = (Throwable) request.getAttribute("javax.servlet.error.exception");
    String exceptionMessage = null;
    exceptionMessage = httpStatus.getReasonPhrase();
    String requestUri = (String) request.getAttribute("javax.serlet.error.request_uri");
    if (requestUri == null) {
        requestUri = "Unknown";
    }//w ww .j av  a2 s.  co  m
    String message = MessageFormat.format("{0} returned for {1}: {2}", statusCode, requestUri,
            exceptionMessage);
    model.addAttribute("errorMessage", message);
    return "customError";
}