1 25 26 package com.j2biz.blogunity.web.actions.blog; 27 28 import javax.servlet.http.HttpServletRequest ; 29 import javax.servlet.http.HttpServletResponse ; 30 31 import org.apache.commons.lang.exception.ExceptionUtils; 32 33 import com.j2biz.blogunity.exception.BlogunityException; 34 import com.j2biz.blogunity.web.ActionResultFactory; 35 import com.j2biz.blogunity.web.IActionResult; 36 import com.j2biz.blogunity.web.actions.AbstractAction; 37 38 public class ErrorAction extends AbstractAction { 39 40 private static final IActionResult ERROR_FORWARD = ActionResultFactory 41 .buildForward("/errorView.vm"); 42 43 private String blogname; 44 45 private Throwable throwable; 46 47 public ErrorAction(String blogname) { 48 this(blogname, null); 49 } 50 51 public ErrorAction(String blogname, Throwable throwable) { 52 this.blogname = blogname; 53 this.throwable = throwable; 54 } 55 56 62 public IActionResult execute(HttpServletRequest request, HttpServletResponse response) 63 throws BlogunityException { 64 65 if (throwable != null) { 66 request.setAttribute("errorMsg", throwable.getMessage()); 67 request.setAttribute("errorStack", ExceptionUtils.getFullStackTrace(throwable)); 68 } 69 70 return ERROR_FORWARD; 71 72 } 73 74 } | Popular Tags |