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


Java HttpStatusCodeException.getStatusText方法代碼示例

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


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

示例1: getHttpErrorMessage

import org.springframework.web.client.HttpStatusCodeException; //導入方法依賴的package包/類
/**
 * 
 * @param error
 * @return Error message containing description of the error. If no
 * description is found, it will return the exception error or HTTP status
 * text message, if present. May return null if no message can be resolved.
 */
protected static String getHttpErrorMessage(HttpStatusCodeException error) {
	String message = null;
	if (error instanceof CloudFoundryException) {
		message = ((CloudFoundryException) error).getDescription();
	}

	if (message == null) {
		message = error.getMessage();
		if (message == null) {
			message = error.getStatusText();
			if (message == null) {
				message = error.getResponseBodyAsString();
			}
		}
	}
	return message;
}
 
開發者ID:eclipse,項目名稱:cft,代碼行數:25,代碼來源:CloudErrorUtil.java

示例2: getResource

import org.springframework.web.client.HttpStatusCodeException; //導入方法依賴的package包/類
private static void getResource(final String url, final Optional<String> mediaType) {
    final HttpHeaders headers = new HttpHeaders();
    if (mediaType.isPresent()) {
        headers.setAccept(asList(parseMediaType(mediaType.get())));
    }
    try {
        final ResponseEntity<String> responseEntity = restTemplate.exchange(
                url,
                GET,
                new HttpEntity<>("parameters", headers), String.class
        );
        content = responseEntity.getBody();
        statusCode = responseEntity.getStatusCode();
    } catch (HttpStatusCodeException e) {
        content = e.getStatusText();
        statusCode = e.getStatusCode();
    }
}
 
開發者ID:otto-de,項目名稱:edison-microservice,代碼行數:19,代碼來源:HealthApi.java

示例3: formatHttpException

import org.springframework.web.client.HttpStatusCodeException; //導入方法依賴的package包/類
private String formatHttpException(HttpStatusCodeException e) {
    try {
        return MessageFormat.format("Response from server: {0} {1}\n {2}",
          e.getStatusCode().value(),
          e.getStatusText(),// getResponseBodyAsString - below
          org.springframework.util.StringUtils.trimWhitespace(e.getResponseBodyAsString()));
    } catch (Exception ex) {
        log.error("Can not format exception {}", e, ex);
    }
    return e.getStatusText();
}
 
開發者ID:codeabovelab,項目名稱:haven-platform,代碼行數:12,代碼來源:DockerServiceImpl.java

示例4: processStatusCodeException

import org.springframework.web.client.HttpStatusCodeException; //導入方法依賴的package包/類
protected void processStatusCodeException(HttpStatusCodeException e) {
    String message;
    try {
        message = MessageFormat.format("Response from server: {0} {1}",
                e.getStatusCode().value(),
                e.getStatusText());
        //we do not read error body, because it contains html code in some cases
    } catch (Exception ex) {
        message = e.getStatusText();
    }
    log.error("Error from server: {}", message, e);

}
 
開發者ID:codeabovelab,項目名稱:haven-platform,代碼行數:14,代碼來源:AbstractV2RegistryService.java

示例5: executeHttpCmd

import org.springframework.web.client.HttpStatusCodeException; //導入方法依賴的package包/類
private ResponseEntity<String> executeHttpCmd(
        HttpCommand cmd,
        BulbCmdTranslator_HTTP cmdTranslator)throws BulbBridgeHwException{
    if(log.isDebugEnabled()){
        log.debug("|- Invocing HTTP Cmd: " + cmd);
    }
    try{
        ResponseEntity<String> resp = restClient.exchange(
                cmd.getUrl(), 
                cmd.getHttpMethod(), 
                cmd.getEntity(), String.class, cmd.getUrlVariables());
        
        if(HttpStatus.OK != resp.getStatusCode()){
            throw new BulbBridgeHwException(
                    resp.getStatusCode().value(), 
                    resp.getStatusCode().getReasonPhrase(), 
                    resp.getBody());
        }
        InvocationResponse invocationResp;
        if( (invocationResp = cmdTranslator.checkResponseForError(resp.getBody())) != null){
            throw new BulbBridgeHwException(invocationResp.getMessage(), null);
        }
        return resp;
    }catch(HttpStatusCodeException bbex){
        throw new BulbBridgeHwException(
                bbex.getStatusCode().value(), bbex.getStatusText(), bbex.getResponseBodyAsString());
    }catch(RestClientException rcex){
        throw new BulbBridgeHwException(rcex.getMessage(), rcex);
    }
}
 
開發者ID:datenstrudel,項目名稱:bulbs-core,代碼行數:31,代碼來源:BulbBridgeHardwareAdapter_REST.java

示例6: asCloudFoundryException

import org.springframework.web.client.HttpStatusCodeException; //導入方法依賴的package包/類
private CloudFoundryException asCloudFoundryException(HttpStatusCodeException exception) {
    String description = getDescriptionFromResponseBody(exception.getResponseBodyAsString());
    return new CloudFoundryException(exception.getStatusCode(), exception.getStatusText(), description);
}
 
開發者ID:SAP,項目名稱:cf-mta-deploy-service,代碼行數:5,代碼來源:CustomControllerClientErrorHandler.java

示例7: createExternalHttpRequestException

import org.springframework.web.client.HttpStatusCodeException; //導入方法依賴的package包/類
protected ExternalHttpRequestException createExternalHttpRequestException(HttpMethod method, URI url, HttpStatusCodeException ex) {
    return new ExternalHttpRequestException(method, url.toString(), ex.getStatusCode(), ex.getStatusText(), ex.getResponseHeaders(), ex.getResponseBodyAsByteArray(), getCharset(ex), jsonMapper, xmlMapper);
}
 
開發者ID:mkopylec,項目名稱:errorest-spring-boot-starter,代碼行數:4,代碼來源:ErrorestTemplate.java


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