Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.makumba.devel
Class ErrorFormatter

    java.lang.Object
      org.makumba.devel.ErrorFormatter

    public class ErrorFormatter

extends Object

The class that performs exception handling. Receives errors in any makumba page and treats them meant to be friendly developer, so he'll see helpful stuff during development and not stupid stacktraces (which are shown only in case of unknown exceptions) also indented for intercepting lack of authorization and show login pages. Most of the code was copied from the TagExceptionServlet.
FIXME the exception hierarchy needs to be reviewed.
FIXME: this class should extend the Filter class (part of refactoring)

Version:
  $Id: ControllerFilter.java 1785 2007-10-12 14:41:55Z manuel_gay $ *
Author:
  Cristian Bogdan, Stefan Baebler, Rudolf Mayer, Filip Kis

Field Summary
`(package private) static Object[][]` | `errors`
`static ArrayList<String>` | `jspReservedWordList`
`static String[]` | `jspReservedWords`
`(package private) static Class<?>[]` | `knownJSPruntimeErrors`
`protected boolean` | `printeHeaderFooter`
`protected ServletContext` | `servletContext`

Constructor Summary
`ErrorFormatter()`
`ErrorFormatter(HttpServletRequest req, ServletContext servletContext, PrintWriter wr, boolean printHeaderFooter)`

Method Summary
`(package private) String` | `formatTagData(HttpServletRequest req)` Displays information about the tag in which the error occurs in a nice way
`String` | `getErrorMessage(HttpServletRequest req)` Returns a string describing the error that occured.
`String` | `getTitle()`
`(package private) void` | `knownError(String title, Throwable t, Throwable original, HttpServletRequest req, PrintWriter wr)` Displays a knows error in the case of an error originating from a tag
`void` | `logError(Throwable t, HttpServletRequest req)` Stores the error details to the database (ErrorLog.mdd)
`(package private) String` | `shortTrace(String s)` Filters out a short part of the stacktrace
`(package private) String` | `shortTrace(String s, int lineNumbers)` Cuts down a stack trace to the given number of lines.
`(package private) String` | `trace(Throwable t)` Prints the stacktrace
`(package private) boolean` | `treatJspException(Throwable original, Throwable t, PrintWriter wr, HttpServletRequest req, ServletContext servletContext, boolean printHeaderFooter, String title)`
`(package private) boolean` | `treatJspRuntimeException(Throwable original, ServletException t, PrintWriter wr, HttpServletRequest req, ServletContext servletContext, boolean printHeaderFooter)`
`(package private) void` | `unknownError(Throwable original, Throwable t, PrintWriter wr, HttpServletRequest req)` Displays an unknown error
`(package private) String` | `unknownErrorMessage(Throwable original, Throwable t, HttpServletRequest req)` Returns a string describing an unknown error.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### errors

    static Object[][] errors

### knownJSPruntimeErrors

    static final Class<?>[] knownJSPruntimeErrors

### servletContext

    protected ServletContext servletContext

### printeHeaderFooter

    protected boolean printeHeaderFooter

### jspReservedWords

    public static String[] jspReservedWords

### jspReservedWordList

    public static ArrayList<String> jspReservedWordList

Constructor Detail

### ErrorFormatter

    public ErrorFormatter()

### ErrorFormatter

    public ErrorFormatter(HttpServletRequest req,
                          ServletContext servletContext,
                          PrintWriter wr,
                          boolean printHeaderFooter)
                   throws IOException,
                          ServletException

Throws:
  `IOException`
  `ServletException`

Method Detail

### getTitle

    public String getTitle()

### logError

    public void logError(Throwable t,
                         HttpServletRequest req)

  Stores the error details to the database (ErrorLog.mdd)

  Parameters:
    `t` - the exception
    `req` - the http request corresponding to the access

### knownError

    void knownError(String title,
                    Throwable t,
                    Throwable original,
                    HttpServletRequest req,
                    PrintWriter wr)

  Displays a knows error in the case of an error originating from a tag

  Parameters:
    `title` - title describing the error
    `t` - the exception
    `original` - the original error exception, not treated
    `req` - the http request corresponding to the access
    `wr` - the PrintWriter on which the error is printed

### formatTagData

    String formatTagData(HttpServletRequest req)

  Displays information about the tag in which the error occurs in a nice way

  Parameters:
    `req` - the http request corresponding to the current access
  Returns:
    The tag error, nicely displayed

### trace

    String trace(Throwable t)

  Prints the stacktrace

  Parameters:
    `t` - the exception
  Returns:
    A String holding the stacktrace

### shortTrace

    String shortTrace(String s)

  Filters out a short part of the stacktrace

  Parameters:
    `s` - the stacktrace to be filtered
  Returns:
    A short version of the stacktrace, meaning only the beginning

### unknownError

    void unknownError(Throwable original,
                      Throwable t,
                      PrintWriter wr,
                      HttpServletRequest req)
                throws IOException,
                       ServletException

  Displays an unknown error

  Parameters:
    `original` - the original error exception, not treated
    `t` - the exception
    `wr` - the PrintWriter on which the error is printed
    `req` - the http request corresponding to the access
  Throws:
    `IOException`
    `ServletException`

### getErrorMessage

    public String getErrorMessage(HttpServletRequest req)

  Returns a string describing the error that occured.

  Parameters:
    `req` -
  Returns:
    the described error

### unknownErrorMessage

    String unknownErrorMessage(Throwable original,
                               Throwable t,
                               HttpServletRequest req)

  Returns a string describing an unknown error. TODO: this code is more or less a copy of unknownError() --> could be optimised

  Parameters:
    `original` -
    `t` -
  Returns:

### shortTrace

    String shortTrace(String s,
                      int lineNumbers)

  Cuts down a stack trace to the given number of lines.

  Parameters:
    `s` - a stacktrace as string.
    `lineNumbers` - the number of lines to be displayed.
  Returns:
    the cut down stack trace.

### treatJspRuntimeException

    boolean treatJspRuntimeException(Throwable original,
                                     ServletException t,
                                     PrintWriter wr,
                                     HttpServletRequest req,
                                     ServletContext servletContext,
                                     boolean printHeaderFooter)

### treatJspException

    boolean treatJspException(Throwable original,
                              Throwable t,
                              PrintWriter wr,
                              HttpServletRequest req,
                              ServletContext servletContext,
                              boolean printHeaderFooter,
                              String title)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Docs generated on 2009-02-25 14:20