use of com.yahoo.search.result.ErrorMessage in project vespa by vespa-engine.
the class DefaultErrorHitTestCase method testErrorHitRenderingWithException.
@SuppressWarnings("null")
public void testErrorHitRenderingWithException() throws IOException {
NullPointerException cause = null;
try {
Object a = null;
a.toString();
} catch (NullPointerException e) {
cause = e;
}
StringWriter w = new StringWriter();
SearchRendererAdaptor.simpleRenderDefaultErrorHit(w, new DefaultErrorHit("test", new ErrorMessage(79, "Myerror", "Mydetail", cause)));
String sep = System.getProperty("line.separator");
assertEquals("<errordetails>\n" + " <error source=\"test\" error=\"Myerror\" code=\"79\">Mydetail\n" + " <cause>\n" + "java.lang.NullPointerException" + sep + "\tat ", w.toString().substring(0, 119 + sep.length()));
}
use of com.yahoo.search.result.ErrorMessage in project vespa by vespa-engine.
the class JsonRendererTestCase method testErrorWithStackTrace.
@Test
public void testErrorWithStackTrace() throws InterruptedException, ExecutionException, IOException {
String expected = "{\n" + " \"root\": {\n" + " \"errors\": [\n" + " {\n" + " \"code\": 1234,\n" + " \"message\": \"top of the day\",\n" + " \"stackTrace\": \"java.lang.Throwable\\n\\tat com.yahoo.search.rendering.JsonRendererTestCase.testErrorWithStackTrace(JsonRendererTestCase.java:732)\\n\",\n" + " \"summary\": \"hello\"\n" + " }\n" + " ],\n" + " \"fields\": {\n" + " \"totalCount\": 0\n" + " },\n" + " \"id\": \"toplevel\",\n" + " \"relevance\": 1.0\n" + " }\n" + "}\n";
Query q = new Query("/?query=a&tracelevel=5&reportCoverage=true");
Result r = new Result(q);
Throwable t = new Throwable();
StackTraceElement[] stack = new StackTraceElement[1];
stack[0] = new StackTraceElement("com.yahoo.search.rendering.JsonRendererTestCase", "testErrorWithStackTrace", "JsonRendererTestCase.java", 732);
t.setStackTrace(stack);
ErrorMessage e = new ErrorMessage(1234, "hello", "top of the day", t);
r.hits().addError(e);
String summary = render(r);
assertEqualJson(expected, summary);
}
use of com.yahoo.search.result.ErrorMessage in project vespa by vespa-engine.
the class PartialFillTestCase method testMergeErrors.
@Test
public void testMergeErrors() {
BadFS4 fs4 = new BadFS4();
Query a = new Query("/?query=foo");
Query b = new Query("/?query=bar");
Result r = new Result(new Query("/?query=ignorethis"));
{
FastHit h = new FastHit();
h.setQuery(a);
h.setFillable();
r.hits().add(h);
}
{
FastHit h = new FastHit();
h.setQuery(b);
h.setFillable();
r.hits().add(h);
}
doFill(fs4, r, "default");
ErrorHit eh = r.hits().getErrorHit();
assertNotNull(eh);
ErrorMessage exp_sub = ErrorMessage.createUnspecifiedError("error");
int n = 0;
for (Iterator<? extends com.yahoo.search.result.ErrorMessage> i = eh.errorIterator(); i.hasNext(); ) {
com.yahoo.search.result.ErrorMessage error = i.next();
switch(n) {
case 0:
assertEquals(exp_sub, error);
break;
case 1:
assertEquals(exp_sub, error);
break;
default:
assertTrue(false);
}
n++;
}
}
Aggregations