You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2013/03/20 08:46:37 UTC
svn commit: r1458674 -
/stanbol/trunk/enhancement-engines/restful-nlp/src/main/java/org/apache/stanbol/enhancer/engines/restful/nlp/impl/RestfulNlpAnalysisEngine.java
Author: rwesten
Date: Wed Mar 20 07:46:37 2013
New Revision: 1458674
URL: http://svn.apache.org/r1458674
Log:
minor: Improved error messages for Exceptions thorwn by the RESTful NLP Analysis Engine. In detail exceptions will now include information provided by the response entity on status codes >= 300. This will allow Stanbol users to see the original stack trace as provided by the RESTful NLP Analyses service (related to STANBOL-893)
Modified:
stanbol/trunk/enhancement-engines/restful-nlp/src/main/java/org/apache/stanbol/enhancer/engines/restful/nlp/impl/RestfulNlpAnalysisEngine.java
Modified: stanbol/trunk/enhancement-engines/restful-nlp/src/main/java/org/apache/stanbol/enhancer/engines/restful/nlp/impl/RestfulNlpAnalysisEngine.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/restful-nlp/src/main/java/org/apache/stanbol/enhancer/engines/restful/nlp/impl/RestfulNlpAnalysisEngine.java?rev=1458674&r1=1458673&r2=1458674&view=diff
==============================================================================
--- stanbol/trunk/enhancement-engines/restful-nlp/src/main/java/org/apache/stanbol/enhancer/engines/restful/nlp/impl/RestfulNlpAnalysisEngine.java (original)
+++ stanbol/trunk/enhancement-engines/restful-nlp/src/main/java/org/apache/stanbol/enhancer/engines/restful/nlp/impl/RestfulNlpAnalysisEngine.java Wed Mar 20 07:46:37 2013
@@ -341,9 +341,19 @@ public class RestfulNlpAnalysisEngine ex
StatusLine statusLine = response.getStatusLine();
HttpEntity entity = response.getEntity();
if (statusLine.getStatusCode() >= 300) {
+ String reason;
+ if(entity != null) {
+ StringBuilder sb = new StringBuilder(statusLine.getReasonPhrase());
+ String message = EntityUtils.toString(entity);
+ if(message != null && !message.isEmpty()){
+ sb.append("\nMessage:\n").append(message);
+ }
+ reason = sb.toString();
+ } else {
+ reason = statusLine.getReasonPhrase();
+ }
EntityUtils.consume(entity);
- throw new HttpResponseException(statusLine.getStatusCode(),
- statusLine.getReasonPhrase());
+ throw new HttpResponseException(statusLine.getStatusCode(), reason);
}
//parse the results
InputStream in = null;