blob: 545e9b3ddc8f659e20b884ae66a5aef843363f53 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.serviceview;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
/**
* Convert exceptions thrown by the internal REST client into a little more helpful responses.
*
* @author Steinar Knutsen
*/
@Provider
public class ProxyErrorMapper implements ExceptionMapper<WebApplicationException> {
@Override
public Response toResponse(WebApplicationException exception) {
StringBuilder msg = new StringBuilder("Invoking (external) web service failed: ");
msg.append(exception.getMessage());
return Response.status(500).entity(msg.toString()).type("text/plain").build();
}
}
|