本文整理汇总了Java中org.springframework.http.HttpStatus.getReasonPhrase方法的典型用法代码示例。如果您正苦于以下问题:Java HttpStatus.getReasonPhrase方法的具体用法?Java HttpStatus.getReasonPhrase怎么用?Java HttpStatus.getReasonPhrase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.http.HttpStatus
的用法示例。
在下文中一共展示了HttpStatus.getReasonPhrase方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleMessageException
import org.springframework.http.HttpStatus; //导入方法依赖的package包/类
/**
* Handles MessageException exception.
*
* @param exception the MessageException instance
* @param request the WebRequest caused exception
* @return the ResponseEntity object instance
*/
@ExceptionHandler(MessageException.class)
protected ResponseEntity<Object> handleMessageException(MessageException exception, WebRequest request) {
HttpStatus status;
switch (exception.getErrorType()) {
case NOT_FOUND:
status = HttpStatus.NOT_FOUND;
break;
case DATA_INVALID:
case PARAMETERS_INVALID:
status = HttpStatus.BAD_REQUEST;
break;
case ALREADY_EXISTS:
status = HttpStatus.CONFLICT;
break;
case AUTH_FAILED:
status = HttpStatus.UNAUTHORIZED;
break;
case OPERATION_TIMED_OUT:
case INTERNAL_ERROR:
default:
status = HttpStatus.INTERNAL_SERVER_ERROR;
break;
}
MessageError error = new MessageError(request.getHeader(CORRELATION_ID), exception.getTimestamp(),
status.value(), status.getReasonPhrase(),
exception.getMessage(), exception.getClass().getSimpleName());
return super.handleExceptionInternal(exception, error, new HttpHeaders(), status, request);
}
示例2: handleExceptionInternal
import org.springframework.http.HttpStatus; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected ResponseEntity<Object> handleExceptionInternal(Exception exception, Object body, HttpHeaders headers,
HttpStatus status, WebRequest request) {
MessageError error = new MessageError(request.getHeader(CORRELATION_ID), System.currentTimeMillis(),
status.value(), status.getReasonPhrase(),
exception.getMessage(), exception.getClass().getSimpleName());
return super.handleExceptionInternal(exception, error, headers, status, request);
}
示例3: CloudFoundryException
import org.springframework.http.HttpStatus; //导入方法依赖的package包/类
public CloudFoundryException(HttpStatus statusCode) {
this(statusCode, statusCode.getReasonPhrase());
}
示例4: create
import org.springframework.http.HttpStatus; //导入方法依赖的package包/类
public static ResultMap create(String message, HttpStatus status) {
return new ResultMap(status.value(), message, status.getReasonPhrase());
}
示例5: handleGenericException
import org.springframework.http.HttpStatus; //导入方法依赖的package包/类
private ExceptionDTO handleGenericException(Throwable e, HttpStatus status) {
return new ExceptionDTO(status.value(), status.getReasonPhrase(), e.getMessage());
}
示例6: RestErrorResponse
import org.springframework.http.HttpStatus; //导入方法依赖的package包/类
protected RestErrorResponse(HttpStatus status, String detailMessage) {
statusCode = status.value();
reasonPhrase = status.getReasonPhrase();
this.detailMessage = detailMessage;
}
示例7: of
import org.springframework.http.HttpStatus; //导入方法依赖的package包/类
public static ErrorResponse of(HttpStatus httpStatus, String message) {
return new ErrorResponse(httpStatus.getReasonPhrase(), message, httpStatus.value());
}
示例8: ApiError
import org.springframework.http.HttpStatus; //导入方法依赖的package包/类
public ApiError(HttpStatus httpStatus, String message, String description) {
statusCode = httpStatus.value();
meaning = httpStatus.getReasonPhrase();
this.message = message;
this.description = description;
}
示例9: getDataFromHttpStatus
import org.springframework.http.HttpStatus; //导入方法依赖的package包/类
private void getDataFromHttpStatus(final HttpStatus status) {
this.status = status.value();
this.reason = status.getReasonPhrase();
}
示例10: getErrorDescription
import org.springframework.http.HttpStatus; //导入方法依赖的package包/类
protected String getErrorDescription(Throwable ex, HttpStatus responseHttpStatus) {
return ex == null ? responseHttpStatus.getReasonPhrase() : ex.getMessage();
}