English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

exceptions

2006-08-02 20:55:28 · 3 answers · asked by chippy 1 in Computers & Internet Programming & Design

3 answers

Basically, a 'throw' means "if this bombs, call the applicable error handler fo handler". So if you hav e "throws FOO", you end up in the error handler for FOO errors., wherever in your program it may be (and there may even be several oFOO handlers defined, and FOO may be subclassed from a more generic error, so that handler may get called as well, etc).

try/catch is basically the reverse of it - it's saying "here is the error handler right here and now,(the catch clause), don't bother going to find someplace to throw to.)

2006-08-02 21:02:28 · answer #1 · answered by Valdis K 6 · 0 0

"throw" throws an exception and "catch" catches it. Self-explanatory, no? Giver and receiver relationship. The only way a try-catch catches an exception is if a function within it throws an exception.

2006-08-03 04:02:09 · answer #2 · answered by Vic 2 · 0 0

try..catch is a block where you throw the runtime exceptions.
throw is the statement used to raise an exception.

try {
...
if(something went wrong)
throw...;
}
catch(exception thrown)
{
handle it
}

2006-08-03 04:03:11 · answer #3 · answered by Indian_Male 4 · 0 0

fedest.com, questions and answers