|
Another interview question which was expecting a true / false answer and I wasn't too sure.
Duplicate http://stackoverflow.com/questions/582095/in-net-what-if-something-fails-in-the-catch-block-will-finally-always-get-call http://stackoverflow.com/questions...
Started by Gais on
, 11 posts
by 11 people.
Answer Snippets (Read the full thread at stackoverflow):
Finally will happen everytime for that try catch block
Finally block is guaranteed....
Generally the finally block is always executed regardless of exceptions (see other answers for more details).
Yes, finally is always executed.
|
|
Basically I've heard that certain conditions will cause .net to blow past the finally block. Does anyone know what those conditions are?
Started by Chris Lively on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Two possibilities:
StackOverflowException ExecutingEngineException The finally block enter the try block so the code in the finally ....
I think finally should always execute.
1.1 days with just the right amount of COM Interop :) . .
|
|
I understand how try-catch works and how try-finally works, but I find myself using those (usually) in two completely different scenarios:
try-finally (or using in C# and VB) is mostly used around some medium-sized code block that uses some resource that...
Started by Heinzi on
, 10 posts
by 10 people.
Answer Snippets (Read the full thread at stackoverflow):
In order to be 100....
So to make it even more are expensive.
Of catch and finally together is to obtain and use resources in a try block, deal with exceptional circumstances in a catch block, and release the resources in the finally block.
|
Ask your Facebook Friends
|
Hey guys, I know it's been some time since I've been gone, if you haven't heard by now I was diagnosed with a stress induced ulcer after I passed out shortly after completing a school assignment.
I apologize for being gone so long, it wasn't my intention...
Started by ShiniKaze on
, 16 posts
by 12 people.
Answer Snippets (Read the full thread at acecombatskies):
ShiniKaze, on 16 December 2011 ....
Sour, on 08 October 2011 - 07:36 PM, said:
My blood type is Haterade .
I missed you.
パンダズカ! Welcome back.
I assumed you left ACS after AC:AH's activity started dying .
I wondered what happened to you.
Welcome back, Shini.
|
|
We got out interview date....Feb 15th!
Started by zeusy99 on
, 11 posts
by 6 people.
Answer Snippets (Read the full thread at diveintoamerica):
We actually booked our flights yesterday, after a nightmare....
Leave them happy for us, will ya? I will sure try! Congrats! Fantastic news!!!
A day before we leave to go back home.. .
Yeehaw!!!! Great news! Ours is 27 February.
So pleased for you guys.
Sweet.
|
|
Consider the following Cocoa/Obj-C code snippets:
MyClass *obj; @try { [obj doSomething]; } @catch (NSException * e) { NSLog(@"Exception occurred: %@", [e description]); } @finally { [obj cleanUp]; }
and
MyClass *obj; @try { [obj doSomething]; } @catch...
Started by Nick Forge on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
@finally is used to clean up when you either don’t catch the exception, or rethrow it, in either case leaving final exception response you don’t need to use @finally , which....
In that case, where you’re squashing the exception, none.
|
|
I had the general view that clean up of resources is done in the finally{} block,
recently I found this particular code snippet in a class and it was overriding the Object class' finalize() method.
protected void finalize() { try { In.close(); Out.close...
Started by Kevin Boyd on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
However, it is often found to clean up such things in finalizers as a last-ditch safety valve should a finally may need the resource before....
Cleaning up in finalize is not guaranteed to occur.
Always clean up things in finally.
|
|
Hi,
In a try/catch/finally block like:
try { } catch() { // code fails here } finally { }
So if there is an exception in the catch block, will finally always get called?
What if there is no finally, will the code after the catch block get run?
Started by Blankman on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
If there's no finally block, the exception from the catch block will just be thrown up will cause the finally block not....
Assuming the process doesn't terminate abruptly (or hang, of course), the finally block will always be executed.
|
|
Hi all
try { // Do stuff } catch (Exception e) { throw; } finally { // Clean up }
In the above block when is the finally block called? Before the throwing of e or is finally called and then catch?
Started by Tom Andrews on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Why not try it:
outer try inner try inner catch inner finally outer catch outer finally....
; } } finally { // Clean up }
As a side note, if you really mean throw e; (that is, throw the same exception trace instead of creating a new one.
|
|
Hi I have a try/finally clause in my script. Is it possible to get the exact error message from within the finally clause?
Started by Goutham on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Refer to: http://www.doughellmann.com/articles/Python-Exception-Handling/
No, at finally time sys.exc_info is all-None, whether the exception, use a bare `raise` else: here you....
You'll want to do that in the except clause, not the finally.
|