[ANN] PrettyException 0.9.1

D

Dmitry V. Sabanin

Hi all,

I want to announce first public release of my library for generating pretty html output
for a given Exception object.

Example:
#
require 'PrettyException'
begin
raise
rescue Exception => e
puts PrettyException.new(e).print
end
# Sample result: http://muravey.net/docs/PrettyException.png

I find it very useful when you develop something for Web and you don't
have access to apache logs. For myself, I'm using PrettyException when I
develop a web site, and when it's time to release it, i turn PrettyException off.

This library depends only on template engine MW::Template, that is yet to be
released for english speaking community, but already available as a Gem.
If you don't have RubyGems installed, you can try to install MW::Template
from a tar.gz archive ( http://rubyforge.org/frs/?group_id=9&release_id=718 ).
You can download PrettyException here: http://rubyforge.org/frs/shownotes.php?release_id=722
Please note, that if you'll try to install library from RubyGems repository, it may be not available for
couple hours, because it takes time to RubyForge to copy Gem to a central repository.
Btw, Gem name is PrettyException.

Hope that this code will interest someone, thanks for your time.
 
K

Kent Sibilev

Interesting. I did almost the same thing when I was developing my last
web application in Ruby. But I also displayed relevant lines of code
which in most cases allowed me to see the problem instantly.

Just an idea.

Cheers,
Kent.
 
V

vruz

But I also displayed relevant lines of code
which in most cases allowed me to see the problem instantly.
Just an idea.

Cheers,
Kent.

good idea, maybe some optional javascript in order to show/hide
offending source code ?

cheers,

vruz
 
D

Dmitry V. Sabanin

Interesting. I did almost the same thing when I was developing my last
web application in Ruby. But I also displayed relevant lines of code
which in most cases allowed me to see the problem instantly.
Did you display code chunks for every backtrace item or only for the one
that is closer to the top?
I'm thinking about what vruz is saying, it would be nice to display some code
inline, when backtrace item was clicked. I'm not decided yet how much lines
do I need to show, i think about this range: (err_line_no-2)..(err_line_no+2).
And as Yuri Leikind pointed me in russian ruby mail list, I could borrow rdoc
syntax highlightning for that.
Just an idea.
I appreciate that.
 
M

Mauricio Fernández

Hi all,

I want to announce first public release of my library for generating pretty html output
for a given Exception object. [...]
I find it very useful when you develop something for Web and you don't
have access to apache logs. For myself, I'm using PrettyException when I
develop a web site, and when it's time to release it, i turn PrettyException off.

This library depends only on template engine MW::Template, that is yet to be
released for english speaking community, but already available as a Gem.

I have just uploaded PrettyException and MW::Template to the preliminary
Ruby Production Archive (RPA) repository
(http://rubyforge.org/frs/?group_id=265):

$ rpa query -x prettyexception
Matching available ports:
name: prettyexception
version: 0.9.1-1
classification: Top.Library
requires: mw-template
description: Create prettified HTML output for Ruby exceptions.

PrettyException is a library to output pretty HTML output for raised
exceptions.


Installation/upgrade is achieved with

$ rpa install prettyexception

and happens atomically, as usual.

=== More information on RPA and rpa-base at
http://rpa-base.rubyforge.org
 
D

Dmitry V. Sabanin

I have just uploaded PrettyException and MW::Template to the preliminary
Ruby Production Archive (RPA) repository
Great to hear :)
Thanks Mauricio, you do a great job!
 
D

David Heinemeier Hansson

I find it very useful when you develop something for Web and you don't
have access to apache logs. For myself, I'm using PrettyException when
I
develop a web site, and when it's time to release it, i turn
PrettyException off.

This is indeed a critical component of any web-application framework.
How easy is it to spot an error, how much information are you supplied
to locate it, and how much time does the fix-test cycle take.

Rails is extremely focused on providing a grade-A handle at all three
crisis points. At http://www.loudthinking.com/share/template_error.html
is a look at an old version of how exception handling in templates was
done in Rails.

In the current version, it's also tracking the nesting of templates (so
when an error occurs in an included template, you can see how included
it up the chain). The template parameter dumps are also made much more
readable by using YAML to do pretty printing.

More importantly, though, is that Rails acts intelligently in the face
of stackdumps and collection inspections. I always found it so funny to
read a dump from Tomcat. 120 lines of framework internals exposed to
the unwitting spectator. Totally oblivious as what to look for.

So as far as it's possible, Rails will determine what's relevant in a
stacktrace (the lines from your own app) and in a collection dump (the
variables you assigned) and then deemphasize the rest.

Of course, these details views inside the internals of a Rails
application are only exposed to requests deemed "local". Everyone else
will automatically be routed to a public error page.

The cool thing about having this distinction in code is that you can
keep it in a production system. So when you need to debug something on
a live system, you'll have a condition present that triggers the local
condition for the developer (like a fixed IP), so he'll get the full
story when he needs to investigate real-world bugs.

And in the real world is where he's likely to need the information the
most. It's where all those odd inputs he never thought about are
popping up. And without a looking glass, it's all too easy to just rip
out your hear in frustration over "this shouldn't be happening!". When
the internals are transparent, the solution is often obvious.

(I cross-posted this to Loud Thinking:
http://www.loudthinking.com/arc/000274.html)
--
David Heinemeier Hansson,
http://www.rubyonrails.org/ -- Web-application framework for Ruby
http://www.instiki.org/ -- A No-Step-Three Wiki in Ruby
http://www.basecamphq.com/ -- Web-based Project Management
http://www.loudthinking.com/ -- Broadcasting Brain
http://www.nextangle.com/ -- Development & Consulting Services
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top