Skip to content

Commit

Permalink
Stop-gap measure to have errors show up in Firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
aaime committed Mar 24, 2017
1 parent 344bfae commit c02e372
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
Expand Up @@ -37,7 +37,7 @@ public OSEOExceptionHandler(List services, GeoServer geoServer) {
@Override
public void handleServiceException(ServiceException exception, Request request) {
HttpServletResponse response = request.getHttpResponse();
response.setContentType(RSS_MIME);
response.setContentType("application/xml");

if (exception instanceof OWS20Exception) {
OWS20Exception ex = (OWS20Exception) exception;
Expand Down
Expand Up @@ -58,6 +58,21 @@ public RSSExceptionTransformer(GeoServerInfo geoServer, Request request) {
public Translator createTranslator(ContentHandler handler) {
return new ExceptionTranslator(handler);
}

public static String getDescription(GeoServerInfo geoServer, ServiceException e) {
StringBuffer sb = new StringBuffer();
OwsUtils.dumpExceptionMessages(e, sb, true);

if (geoServer.getSettings().isVerboseExceptions()) {
ByteArrayOutputStream stackTrace = new ByteArrayOutputStream();
e.printStackTrace(new PrintStream(stackTrace));

sb.append("\nDetails:\n");
sb.append(ResponseUtils.encodeXML(new String(stackTrace.toByteArray())));
}

return sb.toString();
}

class ExceptionTranslator extends LambdaTranslatorSupport {

Expand Down Expand Up @@ -86,22 +101,7 @@ private void channel(ServiceException e) {

private void itemContents(ServiceException e) {
element("title", e.getMessage());
element("description", getDescription(e));
}

private String getDescription(ServiceException e) {
StringBuffer sb = new StringBuffer();
OwsUtils.dumpExceptionMessages(e, sb, true);

if (geoServer.getSettings().isVerboseExceptions()) {
ByteArrayOutputStream stackTrace = new ByteArrayOutputStream();
e.printStackTrace(new PrintStream(stackTrace));

sb.append("\nDetails:\n");
sb.append(ResponseUtils.encodeXML(new String(stackTrace.toByteArray())));
}

return sb.toString();
element("description", getDescription(geoServer, e));
}

private String buildSelfUrl() {
Expand Down
Expand Up @@ -174,7 +174,7 @@ protected void checkValidAtomFeed(Document d) throws SAXException, IOException {
* @throws Exception
*/
protected Document getAsOpenSearchException(String path, int expectedStatus) throws Exception {
return getAsDOM(path, expectedStatus, OSEOExceptionHandler.RSS_MIME);
return getAsDOM(path, expectedStatus, "application/xml"); // OSEOExceptionHandler.RSS_MIME);
}

/**
Expand Down
Expand Up @@ -169,7 +169,7 @@ public void testPagingPartialPages() throws Exception {
@Test
public void testGeoUidCollectionQuery() throws Exception {
Document dom = getAsDOM("oseo/search?uid=LANDSAT8&httpAccept=" + AtomSearchResponse.MIME);
print(dom);
// print(dom);

// basics
assertThat(dom, hasXPath("/at:feed/os:totalResults", equalTo("1")));
Expand Down

0 comments on commit c02e372

Please sign in to comment.