當前位置: 首頁>>代碼示例>>Java>>正文


Java Response.serverError方法代碼示例

本文整理匯總了Java中javax.ws.rs.core.Response.serverError方法的典型用法代碼示例。如果您正苦於以下問題:Java Response.serverError方法的具體用法?Java Response.serverError怎麽用?Java Response.serverError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.ws.rs.core.Response的用法示例。


在下文中一共展示了Response.serverError方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: performMatchingServiceHealthCheck

import javax.ws.rs.core.Response; //導入方法依賴的package包/類
@GET
public Response performMatchingServiceHealthCheck() {
    final AggregatedMatchingServicesHealthCheckResult result = matchingServiceHealthCheckHandler.forceCheckAllMSAs();

    final Response.ResponseBuilder response = result.isHealthy() ? Response.ok() : Response.serverError();
    response.entity(result);
    return response.build();
}
 
開發者ID:alphagov,項目名稱:verify-hub,代碼行數:9,代碼來源:MatchingServiceVersionCheckResource.java

示例2: toResponse

import javax.ws.rs.core.Response; //導入方法依賴的package包/類
@Override
public Response toResponse(@NonNull Exception exception) {
	ResponseBuilder builder;
	StatusType statusInfo;
	if (exception instanceof WebApplicationException) {
		Response response = ((WebApplicationException) exception).getResponse();
		builder = Response.fromResponse(response);
		statusInfo = response.getStatusInfo();
	} else {
		builder = Response.serverError();
		statusInfo = Status.INTERNAL_SERVER_ERROR;
	}

	SimpleExceptionJson simpleExceptionJson = new SimpleExceptionJson(statusInfo.getReasonPhrase(),
			statusInfo.getStatusCode(), exception.getMessage());
	builder.entity(simpleExceptionJson);
	builder.type("application/problem+json");

	if (statusInfo.getFamily() == Family.CLIENT_ERROR) {
		log.debug("Got client Exception", exception);
	} else {
		log.error("Sending error to client", exception);
	}

	return builder.build();
}
 
開發者ID:Mercateo,項目名稱:rest-jersey-utils,代碼行數:27,代碼來源:RFCExceptionMapper.java

示例3: performMatchingServiceHealthCheck

import javax.ws.rs.core.Response; //導入方法依賴的package包/類
@GET
public Response performMatchingServiceHealthCheck() {
    final AggregatedMatchingServicesHealthCheckResult result = matchingServiceHealthCheckHandler.handle();

    final Response.ResponseBuilder response = result.isHealthy() ? Response.ok() : Response.serverError();
    response.entity(result);
    return response.build();
}
 
開發者ID:alphagov,項目名稱:verify-hub,代碼行數:9,代碼來源:MatchingServiceHealthCheckResource.java


注:本文中的javax.ws.rs.core.Response.serverError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。