Search in sources :

Example 16 with ErrorMessage

use of com.yahoo.processing.request.ErrorMessage in project vespa by vespa-engine.

the class SearchRendererAdaptor method simpleRenderErrorHit.

/**
 * Renders this hit as XML, disregarding the given template.
 * The main error will be rendered first, the all the following errors.
 */
public boolean simpleRenderErrorHit(Writer writer, com.yahoo.search.result.ErrorHit errorHit) throws IOException {
    XMLWriter xmlWriter = (writer instanceof XMLWriter) ? (XMLWriter) writer : new XMLWriter(writer, 10, -1);
    xmlWriter.openTag("errordetails");
    for (Iterator i = errorHit.errorIterator(); i.hasNext(); ) {
        ErrorMessage error = (ErrorMessage) i.next();
        rendererErrorHitMessageMessage(xmlWriter, errorHit, error);
    }
    xmlWriter.closeTag();
    return true;
}
Also used : Iterator(java.util.Iterator) ErrorMessage(com.yahoo.processing.request.ErrorMessage) XMLWriter(com.yahoo.text.XMLWriter)

Example 17 with ErrorMessage

use of com.yahoo.processing.request.ErrorMessage in project vespa by vespa-engine.

the class WandSearcherTestCase method requireThatErrorIsReturnedOnInvalidTokenList.

@Test
public void requireThatErrorIsReturnedOnInvalidTokenList() {
    Query q = buildQuery(VESPA_FIELD, "{a1,b:1}", null, null, null, null);
    Result r = exec.search(q);
    ErrorMessage msg = r.hits().getError();
    assertNotNull(msg);
    assertEquals(INVALID_QUERY_PARAMETER.code, msg.getCode());
    assertEquals("'{a1,b:1}' is not a legal sparse vector string: Expected ':' starting at position 3 but was ','", msg.getDetailedMessage());
}
Also used : Query(com.yahoo.search.Query) ErrorMessage(com.yahoo.processing.request.ErrorMessage) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 18 with ErrorMessage

use of com.yahoo.processing.request.ErrorMessage in project vespa by vespa-engine.

the class WandSearcherTestCase method requireThatErrorIsReturnedOnUnknownField.

@Test
public void requireThatErrorIsReturnedOnUnknownField() {
    Query q = buildDefaultQuery("unknown", "50");
    Result r = exec.search(q);
    ErrorMessage msg = r.hits().getError();
    assertNotNull(msg);
    assertEquals(INVALID_QUERY_PARAMETER.code, msg.getCode());
    assertEquals("Field 'unknown' was not found in index facts for search definitions [test]", msg.getDetailedMessage());
}
Also used : Query(com.yahoo.search.Query) ErrorMessage(com.yahoo.processing.request.ErrorMessage) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 19 with ErrorMessage

use of com.yahoo.processing.request.ErrorMessage in project vespa by vespa-engine.

the class RequestTestCase method testErrorMessages.

@Test
public void testErrorMessages() {
    Request r = new Request();
    r.errors().add(new ErrorMessage("foo"));
    r.errors().add(new ErrorMessage("bar"));
    assertEquals(2, r.errors().size());
    assertEquals("foo", r.errors().get(0).getMessage());
    assertEquals("bar", r.errors().get(1).getMessage());
}
Also used : Request(com.yahoo.processing.Request) ErrorMessage(com.yahoo.processing.request.ErrorMessage) Test(org.junit.Test)

Aggregations

ErrorMessage (com.yahoo.processing.request.ErrorMessage)19 Test (org.junit.Test)13 Chain (com.yahoo.component.chain.Chain)3 Processor (com.yahoo.processing.Processor)3 Request (com.yahoo.processing.Request)2 Query (com.yahoo.search.Query)2 Result (com.yahoo.search.Result)2 XMLWriter (com.yahoo.text.XMLWriter)2 Iterator (java.util.Iterator)2 Response (com.yahoo.jdisc.Response)1 AsynchronousSectionedRenderer (com.yahoo.processing.rendering.AsynchronousSectionedRenderer)1 ProcessingRenderer (com.yahoo.processing.rendering.ProcessingRenderer)1 Renderer (com.yahoo.processing.rendering.Renderer)1 IOException (java.io.IOException)1 IdentityHashMap (java.util.IdentityHashMap)1