[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

recue-raise vs catch-throw

raja

7/12/2007 9:33:00 AM

Dear All

I wonder if anyone could better explain me the difference between
rescue-raise and catch-throw paradigms

Thanks in Advance
Raja

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

8 Answers

Florian Aßmann

7/12/2007 9:43:00 AM

0

Hi Vin Raja,
> I wonder if anyone could better explain me the difference between
> rescue-raise and catch-throw paradigms
imho, with rescue you catch exceptions and with catch and throw
(opposite of continuations :) you skip the rest of a catch block with an
optional return value...

see http://whytheluckystiff.net/ruby/pickaxe/html/tut_excep...
for a more detailed explanation...

Regards
Florian


Bertram Scharpf

7/12/2007 9:52:00 AM

0

Hi,

Am Donnerstag, 12. Jul 2007, 18:32:49 +0900 schrieb Vin Raja:
> I wonder if anyone could better explain me the difference between
> rescue-raise and catch-throw paradigms

I never felt no need to use catch-throw anywhere.
Maybe there is some special case I did not get in touch up
to now.

Bertram


--
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-...

raja

7/12/2007 10:26:00 AM

0


>Florian
>see http://whytheluckystiff.net/ruby/pickaxe/html/tut_excep...
Thanks


>Bertram Scharpf wrote:
> I never felt no need to use catch-throw anywhere.
Even I do wonder


---
Raja



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

Robert Klemme

7/12/2007 11:11:00 AM

0

2007/7/12, Vin Raja <vineetraja@gmail.com>:
>
> >Florian
> >see http://whytheluckystiff.net/ruby/pickaxe/html/tut_excep...
> Thanks
>
>
> >Bertram Scharpf wrote:
> > I never felt no need to use catch-throw anywhere.
> Even I do wonder

raise / rescue is for error handling. catch / throw is for control
flow. catch / flow is especially useful if you have multiple exits for
a piece of code. Although I have to say I rarely felt the need for
this. Basically it's the same as a method with multiple "return"s only
you do not leave the current scope.

Kind regards

robert

Mariusz Pekala

7/12/2007 11:45:00 AM

0

On 2007-07-12 18:32:49 +0900 (Thu, Jul), Vin Raja wrote:
> Dear All
>
> I wonder if anyone could better explain me the difference between
> rescue-raise and catch-throw paradigms
>
> Thanks in Advance
> Raja

With raise you operate on descendants of Exception class.
With throw you can use any object.

I suppose this is the main difference.

Raise should be used for errors and similiar things, while throw just
for standard operations. It would be very confusing for the reader of
the code if raise would be used to pass data, and not for being the
signal that some dangerous/unusual condition may be handled here.
I guess.

Of course, I may be wrong ;-)

--
I have tried to Google this question, but Google said:
"Application error, Rails application failed to start properly"

Mariusz Pekala

7/12/2007 11:49:00 AM

0

On 2007-07-12 19:26:11 +0900 (Thu, Jul), Vin Raja wrote:
> >Bertram Scharpf wrote:
> > I never felt no need to use catch-throw anywhere.
> Even I do wonder
>

Some deep recursive search comes to mind..


--
I have tried to Google this question, but Google said:
"Application error, Rails application failed to start properly"

raja

7/12/2007 12:42:00 PM

0

Mariusz PÄ?kala wrote:
> Some deep recursive search comes to mind..

and that smells of a goto usecase !

or perhaps even I could be wrong :)



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

Robert Klemme

7/12/2007 1:24:00 PM

0

2007/7/12, Vin Raja <vineetraja@gmail.com>:> Mariusz Pekala wrote:> > Some deep recursive search comes to mind..>> and that smells of a goto usecase !Oh no! He used the g-word!! Decontaminate the mailing list!;-)robert