当前位置: 首页>>代码示例>>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;未经允许,请勿转载。