2 Replies Latest reply on Feb 4, 2008 10:57 AM by franky.b

    Error handling with error pages

      Hi there,

      my goal is to add a custom error page to an existing seam app which should display both the (technical) description of the error with <h:messages> and a short sentence that can be understand by a normal user (e.g. "connection to database failed. please try again later") and depends on what kind of error occured, of course.
      This should be achived with a singe error page.

      I am not able to change the code of the app, so I can not raise custom exceptions in my beans.

      Therefore, I started with an entry in exceptions.xml, which redirects two exemplary kinds of errors that occur before render phase to my generic error page.

      <exception class="java.lang.RuntimeException">
       <redirect view-id="/genericError.xhtml">
       </redirect>
      </exception>
       <exception class="javax.servlet.ServletException">
       <redirect view-id="/genericError.xhtml"></redirect>
       </exception>-->
      


      Well, now I can access the technical error message in genericError.xhtml with
      <h:messages globalOnly="true" styleClass="message" />


      But how can I detect because of which of the two exceptions the error page was displayed, so that I can show the correct textual message? Is there something like a global error object?

      Or can I pass the desired message or the kind of exception to my genericError.xhtml in some way?

      I tried <param ..> but I did not get it to work.

      Thanks in advance,
      Frank