[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Sending mail when exception occured

james_b

3/3/2006 11:49:00 PM

Michal Lomnicki wrote:
> Hello!

Hello!

> Is it correct way?

Does it work? Does it allow you to go back to solving more interesting
or valuable problems?

Not always the best criteria, but worth considering.

--
James Britt

http://www.ru... - Ruby Help & Documentation
http://www.artima.c... - The Journal By & For Rubyists
http://www.rub... - The Ruby Store for Ruby Stuff
http://web2.0val... - We're the Dot in Web 2.0


3 Answers

Michal Lomnicki

3/4/2006 12:17:00 AM

0

>> Is it correct way?
>
> Does it work? Does it allow you to go back to solving more interesting
> or valuable problems?

Yes, it works, but I`m not sure if it works in all cases.
I`m just courious about other solution of this problem:)

--
Posted via http://www.ruby-....


Kevin Brown

3/5/2006 4:40:00 AM

0

On Friday 03 March 2006 18:16, Michal Lomnicki wrote:
> >> Is it correct way?
> >
> > Does it work? Does it allow you to go back to solving more interesting
> > or valuable problems?
>
> Yes, it works, but I`m not sure if it works in all cases.
> I`m just courious about other solution of this problem:)

Unless I completely misunderstood you, why not just do:

begin
# Do whatever it is you're going to do
rescue Exception => e
# Create your email
message_string = "An error has occurred. Backtrace: #{e.backtrace}"
# Email it off however.
end

I get the strange feeling though that you want more than this...?


Michal Lomnicki

3/5/2006 8:53:00 AM

0

> Unless I completely misunderstood you, why not just do:
>
> begin
> # Do whatever it is you're going to do
> rescue Exception => e
> # Create your email
> message_string = "An error has occurred. Backtrace: #{e.backtrace}"
> # Email it off however.
> end
>

Of course it`s the simplest way, but I`ll have to invoke that in every
rescue block. So, let`s say that there is _uncatched_ exception, even
then mail should be sent. I redefined set_backtrace in Exception class.

> I get the strange feeling though that you want more than this...?

I hope that now my problem is clear.

--
Posted via http://www.ruby-....