Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error Page with Optional Stack Trace

 
rastin purr
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,
I'd like to have a page that display some business exception (eg. InsufficientFundException) with the possibility of displaying the stack trace of the business exception as well when clicking on a link (say for example). Say, the business exception (eg. InsufficientFundException) occurred and a page saying Insufficient Fund was displayed. There is a link at the bottom saying "click to display details" which would print out the exception stack trace. Is this possible? has anyone done this before? thanks for the help guys
Ras
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13062
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since the exception information is long gone when the user sees the page, you will have to include it all in that page - possibly with Javascript to pop up an alert box with all of the stack trace. HINT - use <pre> to format the stack trace or it gets unreadable.
Bill
 
rastin purr
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear William,
Thanks for the reply. Could you explain further please? Prefereably with some code sample. Thanks a lot.
With Regards,
Ras
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We either show the stack trace or we don't.
ie internal pages display the stack trace on the page, external (internet) page do not.
Personally I say that if you are going to show the exception, show it. Don't make it a 2 step process to get there.
Dave
 
rastin purr
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David,
Can you explain a bit more about the internal pages and external pages you mentioned? Why would a web site need both pages? Thanks for the explanation in advance. Is there a way to make the two step process comes true? Thanks again
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By internal and External I'm referring to pages viewed over the internet and pages that are only for internal, company use.
When we build a web-app that has an administration component, we print the stack trace on the internal admin pages, but never provide the stack trace to the outside world.
If you want to provide the stack trace in a two step process:
  • when the exception is detected, put it on the session and redirect to the error page.
  • if the user hits the button, call the page with an extra parameter.
  • when the parameter is detected, load the Exception from the session and display it


  • The reason I don't like doing things like this is that you are using the session to support request-scope data. The exception remains on the session even though it might never be used again by the user. You can't remove the exception in case they reload the page.
    Anyway, hope this helps.
    Dave
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic