下面列出了org.springframework.http.HttpStatus#name ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
TaskanaErrorData(HttpStatus stat, Exception ex, WebRequest req) {
this.timestamp = new Date();
this.status = stat.value();
this.error = stat.name();
this.exception = ex.getClass().getName();
this.message = ex.getMessage();
this.path = req.getDescription(false);
if (this.path.startsWith("uri=")) {
this.path = this.path.substring(4);
}
}
@Override
public Tags apply(ServerWebExchange exchange) {
String outcome = "CUSTOM";
String status = "CUSTOM";
String httpStatusCodeStr = "NA";
String httpMethod = exchange.getRequest().getMethodValue();
// a non standard HTTPS status could be used. Let's be defensive here
// it needs to be checked for first, otherwise the delegate response
// who's status DIDN'T change, will be used
if (exchange.getResponse() instanceof AbstractServerHttpResponse) {
Integer statusInt = ((AbstractServerHttpResponse) exchange.getResponse())
.getStatusCodeValue();
if (statusInt != null) {
status = String.valueOf(statusInt);
httpStatusCodeStr = status;
HttpStatus resolved = HttpStatus.resolve(statusInt);
if (resolved != null) {
// this is not a CUSTOM status, so use series here.
outcome = resolved.series().name();
status = resolved.name();
}
}
}
else {
HttpStatus statusCode = exchange.getResponse().getStatusCode();
if (statusCode != null) {
httpStatusCodeStr = String.valueOf(statusCode.value());
outcome = statusCode.series().name();
status = statusCode.name();
}
}
return Tags.of("outcome", outcome, "status", status, "httpStatusCode",
httpStatusCodeStr, "httpMethod", httpMethod);
}
/**
* Construct a new instance with an {@link HttpStatus}.
* @param statusCode the status code
*/
protected HttpStatusCodeException(HttpStatus statusCode) {
this(statusCode, statusCode.name(), null, null, null);
}
/**
* Construct a new instance with an {@link HttpStatus}.
* @param statusCode the status code
*/
protected HttpStatusCodeException(HttpStatus statusCode) {
this(statusCode, statusCode.name(), null, null, null);
}
/**
* Construct a new instance with an {@link HttpStatus}.
* @param statusCode the status code
*/
protected HttpStatusCodeException(HttpStatus statusCode) {
this(statusCode, statusCode.name(), null, null, null);
}
/**
* Construct a new instance of {@code HttpStatusCodeException} based on an
* {@link HttpStatus}.
* @param statusCode the status code
*/
protected HttpStatusCodeException(HttpStatus statusCode) {
this(statusCode, statusCode.name(), null, null, null);
}