Java Code Examples for com.alibaba.dubbo.rpc.RpcException#UNKNOWN_EXCEPTION

The following examples show how to use com.alibaba.dubbo.rpc.RpcException#UNKNOWN_EXCEPTION . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DubboParser.java    From brave with Apache License 2.0 6 votes vote down vote up
/**
 * This library is no-longer being released, so it should not have any maintenance on error codes.
 * The error codes here were defined in 2012.
 */
@Nullable static String errorCode(Throwable error) {
  if (error instanceof RpcException) {
    int code = ((RpcException) error).getCode();
    switch (code) {
      case RpcException.UNKNOWN_EXCEPTION:
        return "UNKNOWN_EXCEPTION";
      case RpcException.NETWORK_EXCEPTION:
        return "NETWORK_EXCEPTION";
      case RpcException.TIMEOUT_EXCEPTION:
        return "TIMEOUT_EXCEPTION";
      case RpcException.BIZ_EXCEPTION:
        return "BIZ_EXCEPTION";
      case RpcException.FORBIDDEN_EXCEPTION:
        return "FORBIDDEN_EXCEPTION";
      case RpcException.SERIALIZATION_EXCEPTION:
        return "SERIALIZATION_EXCEPTION";
      default:
        return String.valueOf(code);
    }
  }
  return null;
}
 
Example 2
Source File: RestExpressInvoker.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public static byte[] post(String url, byte[] requestContent, Map<String, String> headerMap) throws IOException {
	HttpPost httpPost = new HttpPost(url);
	if (requestContent != null) {
		HttpEntity httpEntity = new ByteArrayEntity(requestContent);
		httpPost.setEntity(httpEntity);
	}
	if (headerMap != null) {
		for (Map.Entry<String, String> entry : headerMap.entrySet()) {
			httpPost.setHeader(entry.getKey(), entry.getValue());
		}
	}
	HttpResponse response = httpclient.execute(httpPost);
	int responseCode = response.getStatusLine().getStatusCode();
	if (responseCode == HttpStatus.SC_OK || responseCode == HttpStatus.SC_CREATED
			|| responseCode == HttpStatus.SC_ACCEPTED || responseCode == HttpStatus.SC_NO_CONTENT) {
		HttpEntity responseEntity = response.getEntity();
		if (responseEntity != null) {
			return EntityUtils.toByteArray(responseEntity);
		}
	} else if (responseCode == HttpStatus.SC_NOT_FOUND) {
		throw new RpcException(RpcException.UNKNOWN_EXCEPTION, "not found service for url [" + url + "]");
	} else if (responseCode == HttpStatus.SC_INTERNAL_SERVER_ERROR) {
		throw new RpcException(RpcException.NETWORK_EXCEPTION, "occur an exception at server end.");
	} else {
		throw new RpcException(RpcException.NETWORK_EXCEPTION, "Unknow HttpStatus Code");
	}
	return null;
}
 
Example 3
Source File: HttpInvoker.java    From dubbo-plus with Apache License 2.0 5 votes vote down vote up
public static byte[] post(String url,byte[] requestContent,Map<String,String> headerMap) throws IOException {
    HttpPost httpPost = new HttpPost(url);
    if(requestContent!=null){
        HttpEntity httpEntity = new ByteArrayEntity(requestContent);
        httpPost.setEntity(httpEntity);
    }
    if(headerMap!=null){
        Header[] headers = new Header[headerMap.size()];
        int index=0;
        for(Map.Entry<String,String> entry:headerMap.entrySet()){
            Header header = new BasicHeader(RestfulConstants.RESTFUL_HEADER_KEY_PREFIX+entry.getKey(),entry.getValue());
            headers[index]=header;
            index++;
        }
        httpPost.setHeaders(headers);
    }
    CloseableHttpResponse response =  httpclient.execute(httpPost);
    int responseCode = response.getStatusLine().getStatusCode();
    if(responseCode==200){
        HttpEntity responseEntity = response.getEntity();
        if(responseEntity!=null){
            return EntityUtils.toByteArray(responseEntity);
        }
    }else if(responseCode==404){
        throw new RpcException(RpcException.UNKNOWN_EXCEPTION,"not found service for url ["+url+"]");
    }else if(responseCode==500){
        throw new RpcException(RpcException.NETWORK_EXCEPTION,"occur an exception at server end.");
    }
    return null;
}
 
Example 4
Source File: AbstractProxyProtocol.java    From dubbo-2.6.5 with Apache License 2.0 4 votes vote down vote up
protected int getErrorCode(Throwable e) {
    return RpcException.UNKNOWN_EXCEPTION;
}
 
Example 5
Source File: AbstractProxyProtocol.java    From dubbox with Apache License 2.0 4 votes vote down vote up
protected int getErrorCode(Throwable e) {
    return RpcException.UNKNOWN_EXCEPTION;
}
 
Example 6
Source File: AbstractProxyProtocol.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
protected int getErrorCode(Throwable e) {
    return RpcException.UNKNOWN_EXCEPTION;
}
 
Example 7
Source File: AbstractProxyProtocol.java    From dubbo3 with Apache License 2.0 4 votes vote down vote up
protected int getErrorCode(Throwable e) {
    return RpcException.UNKNOWN_EXCEPTION;
}
 
Example 8
Source File: AbstractProxyProtocol.java    From dubbox with Apache License 2.0 4 votes vote down vote up
protected int getErrorCode(Throwable e) {
    return RpcException.UNKNOWN_EXCEPTION;
}
 
Example 9
Source File: AbstractProxyProtocol.java    From dubbox with Apache License 2.0 4 votes vote down vote up
protected int getErrorCode(Throwable e) {
    return RpcException.UNKNOWN_EXCEPTION;
}