luni, 2 noiembrie 2015

[OmniFaces utilities (2.0)] Print the stack trace of the given exception


[OmniFaces utilities] The printStackTrace() function prints the stack trace of the given exception.

Function:
Usage:

The of:printStackTrace() can be useful in an error page. Per example, in an error page we can display different information about the error, like this:

Date/time: #{of:formatDate(now, 'yyyy-MM-dd HH:mm:ss')}
User agent: #{header['user-agent']}
User IP: #{request.remoteAddr}
Request URI: #{requestScope['javax.servlet.error.request_uri']}
Ajax request: #{facesContext.partialViewContext.ajaxRequest ? 'Yes' : 'No'}
Status code: #{requestScope['javax.servlet.error.status_code']}
Exception type: #{requestScope['javax.servlet.error.exception_type']}
Exception message: #{requestScope['javax.servlet.error.message']}

Beside these, we can also display the error stack trace, as below:
#{of:printStackTrace(requestScope['javax.servlet.error.exception'])}

Note: You can use this is combination with OmniFaces FullAjaxExceptionHandler.

Niciun comentariu:

Trimiteți un comentariu