Commit 63fd0a25 by Suma S

Merge pull request #100 from sumashivaprasad/BUG_37105

Fixed BUG-37424
parents 44c4519c e2392607
......@@ -55,6 +55,7 @@ public class MetadataServiceClient {
public static final String DEFINITION = "definition";
public static final String ERROR = "error";
public static final String STACKTRACE = "stackTrace";
public static final String REQUEST_ID = "requestId";
public static final String RESULTS = "results";
public static final String COUNT = "count";
......
......@@ -188,7 +188,7 @@ public class GraphBackedTypeStore implements ITypeStore {
break;
default:
throw new IllegalArgumentException("Unhandled type category " + attrDataType.getTypeCategory());
throw new IllegalArgumentException("Attribute cannot reference instances of type : " + attrDataType.getTypeCategory());
}
for (IDataType attrType : attrDataTypes) {
......
......@@ -30,6 +30,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
/**
......@@ -98,7 +99,20 @@ public final class Servlets {
}
public static Response getErrorResponse(Throwable e, Response.Status status) {
return getErrorResponse(e.getMessage(), status);
Response response = getErrorResponse(e.getMessage(), status);
JSONObject responseJson = (JSONObject) response.getEntity();
try {
responseJson.put(MetadataServiceClient.STACKTRACE, printStackTrace(e));
} catch (JSONException e1) {
LOG.warn("Could not construct error Json rensponse", e1);
}
return response;
}
private static String printStackTrace(Throwable t) {
StringWriter sw = new StringWriter();
t.printStackTrace(new PrintWriter(sw));
return sw.toString();
}
public static Response getErrorResponse(String message, Response.Status status) {
......@@ -108,7 +122,7 @@ public final class Servlets {
errorJson.put(MetadataServiceClient.ERROR, errorEntity);
errorEntity = errorJson;
} catch (JSONException jsonE) {
LOG.warn("Could not construct error Json rensponse");
LOG.warn("Could not construct error Json rensponse", jsonE);
}
return Response
.status(status)
......
......@@ -199,6 +199,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
JSONObject response = new JSONObject(responseAsString);
Assert.assertNotNull(response.get(MetadataServiceClient.ERROR));
Assert.assertNotNull(response.get(MetadataServiceClient.STACKTRACE));
}
@Test(dependsOnMethods = "testSubmitEntity")
......@@ -238,6 +239,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
JSONObject response = new JSONObject(responseAsString);
Assert.assertNotNull(response.get(MetadataServiceClient.ERROR));
Assert.assertNotNull(response.get(MetadataServiceClient.STACKTRACE));
}
@Test
......@@ -395,6 +397,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
JSONObject response = new JSONObject(responseAsString);
Assert.assertNotNull(response.get(MetadataServiceClient.ERROR));
Assert.assertNotNull(response.get(MetadataServiceClient.STACKTRACE));
}
private void createHiveTypes() throws Exception {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment