You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ad...@apache.org on 2007/12/27 18:54:37 UTC
svn commit: r607100 -
/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFopViewHandler.java
Author: adrianc
Date: Thu Dec 27 09:54:35 2007
New Revision: 607100
URL: http://svn.apache.org/viewvc?rev=607100&view=rev
Log:
Improved error handling in the FOP view handler.
Modified:
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFopViewHandler.java
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFopViewHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFopViewHandler.java?rev=607100&r1=607099&r2=607100&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFopViewHandler.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFopViewHandler.java Thu Dec 27 09:54:35 2007
@@ -68,7 +68,8 @@
screens.getContext().put("formStringRenderer", new FoFormRenderer(request, response));
screens.render(page);
} catch (Exception e) {
- throw createException("Problems with the response writer/output stream", e, request, response);
+ renderError("Problems with the response writer/output stream", e, request, response);
+ return;
}
// set the input source (XSL-FO) and generate the output stream of contentType
@@ -84,7 +85,8 @@
Fop fop = ApacheFopWorker.createFopInstance(out, contentType);
ApacheFopWorker.transform(src, null, fop);
} catch (Exception e) {
- throw createException("Unable to transform FO file", e, request, response);
+ renderError("Unable to transform FO file", e, request, response);
+ return;
}
// set the content type and length
response.setContentType(contentType);
@@ -95,25 +97,25 @@
out.writeTo(response.getOutputStream());
response.getOutputStream().flush();
} catch (IOException e) {
- throw createException("Unable write to browser OutputStream", e, request, response);
+ renderError("Unable to write to OutputStream", e, request, response);
}
}
- protected ViewHandlerException createException(String msg, Exception e, HttpServletRequest request, HttpServletResponse response) {
+ protected void renderError(String msg, Exception e, HttpServletRequest request, HttpServletResponse response) throws ViewHandlerException {
Debug.logError(msg + ": " + e, module);
try {
Writer writer = new StringWriter();
ScreenRenderer screens = new ScreenRenderer(writer, null, new HtmlScreenRenderer());
screens.populateContextForRequest(request, response, servletContext);
- screens.getContext().put("errorMessage", e.toString());
+ screens.getContext().put("errorMessage", msg + ": " + e);
screens.render(DEFAULT_ERROR_TEMPLATE);
response.setContentType("text/html");
- response.getOutputStream().write(writer.toString().getBytes());
+ response.getWriter().write(writer.toString());
writer.close();
} catch (Exception x) {
Debug.logError("Multiple errors rendering FOP", module);
+ throw new ViewHandlerException("Multiple errors rendering FOP", x);
}
- return new ViewHandlerException(msg, e);
}
}