View Javadoc
1   package info.ejava.examples.ejb.cdisales.web;
2   
3   import java.io.PrintWriter;
4   import java.io.Serializable;
5   import java.io.StringWriter;
6   
7   import javax.enterprise.context.SessionScoped;
8   import javax.inject.Named;
9   
10  @SuppressWarnings("serial")
11  @Named("errorController")
12  @SessionScoped
13  public class ErrorController implements Serializable {
14  
15      private String error;
16      private Exception exception;
17          
18      public String getError() {
19          return error;
20      }
21      public void setError(String error) {
22          this.error = error;
23      }
24      
25      public String getStackTrace() {
26          if (exception != null) {
27              StringWriter sw = new StringWriter();
28              exception.printStackTrace(new PrintWriter(sw));
29              return sw.toString();
30          } else {
31              return null;
32          }
33      }
34      
35      public Exception getException() {
36          return exception;
37      }
38      public void setException(Exception exception) {
39          this.exception = exception;
40      }
41  }