tagged [try-catch]
`Fault` keyword in try block
`Fault` keyword in try block While exploring an assembly in reflector I stumbled upon a `fault` keyword in a compiler generated class. Do any of you know the meaning if this keyword? ``` Private Funct...
Try-Catch-End Try in VBScript doesn't seem to work
Try-Catch-End Try in VBScript doesn't seem to work I'm the following code: but I'm getting the error `Statement expected` in the catch clause. Does anyone know how I can catch/throw exceptions in VBSc...
How to get the name of the method that caused the exception
How to get the name of the method that caused the exception My code looks as below. I need a way to show the method name, suppose in the above case if any exception is thrown in the GetAllProductCateg...
How do I prevent node.js from crashing? try-catch doesn't work
How do I prevent node.js from crashing? try-catch doesn't work From my experience, a php server would throw an exception to the log or to the server end, but node.js just simply crashes. Surrounding m...
- Modified
- 14 May at 02:4
Is try/catch around whole C# program possible?
Is try/catch around whole C# program possible? A C# program is invoked by: I'd like to put a try/catch around the whole thing to trap any uncaught exceptions. When I put it around this Run method, exc...
Difference between try-finally and try-catch
Difference between try-finally and try-catch What's the difference between and I like the second version better because it gives me access to the Throwable. Is there any logical difference or a pr
- Modified
- 18 May at 06:15
Being specific with Try / Catch
Being specific with Try / Catch Being new to programming I have only just found out that you can specifically catch certain types of errors and tie code to only that type of error. I've been researchi...
Catch vs Catch (Exception e) and Throw vs Throw e
Catch vs Catch (Exception e) and Throw vs Throw e Are these two code examples the same? and have the same output, and the result is also the same if I write or . Main: Code 1: ``` static void A() { ...
Is it ever okay to catch an exception and do nothing?
Is it ever okay to catch an exception and do nothing? From my experience, I generally wouldn't do this. But if I had a piece of functionality that say, uses a 3rd party COM assembly which occasionally...
- Modified
- 28 Apr at 01:52
Will code in a Finally statement fire if I return a value in a Try block?
Will code in a Finally statement fire if I return a value in a Try block? I'm reviewing some code for a friend and say that he was using a return statement inside of a try-finally block. Does the code...
How can I avoid duplicated try catch blocks
How can I avoid duplicated try catch blocks I have several methods that look like this: Can I change the code to look like? How can I implement this custom attribute? and what are the pros and cons of...
- Modified
- 12 Sep at 07:40
If I return out of a try/finally block in C# does the code in the finally always run?
If I return out of a try/finally block in C# does the code in the finally always run? It seems like it does as per some initial testing, but what I'd like to know is if it is to return or if in some c...
- Modified
- 9 Feb at 16:16
Why is "except: pass" a bad programming practice?
Why is "except: pass" a bad programming practice? I often see comments on other Stack Overflow questions about how the use of `except: pass` is discouraged. Why is this bad? Sometimes I just don't car...
- Modified
- 5 Jul at 10:0
Why does Try-Catch require curly braces
Why does Try-Catch require curly braces Just curious: Why is the syntax for [try catch in C#](http://msdn.microsoft.com/en-us/library/vstudio/0yd65esw.aspx) (Java also?) hard coded for multiple statem...
Is there a situation when it's appropriate to use empty catch block?
Is there a situation when it's appropriate to use empty catch block? > [Why are empty catch blocks a bad idea?](https://stackoverflow.com/questions/1234343/why-are-empty-catch-blocks-a-bad-idea) [Is...
- Modified
- 23 May at 12:14
pros and cons of TryCatch versus TryParse
pros and cons of TryCatch versus TryParse What are the pros and cons of using either of the following approaches to pulling out a double from an object? Beyond just personal preferences, issues I'm lo...
C# - Try-Catch-Finally on Return
C# - Try-Catch-Finally on Return I have the following code: ``` public DataTable GetAllActiveUsers() { DataTable dataTable = new DataTable(); try { connection.Open(); ...
C# catch a stack overflow exception
C# catch a stack overflow exception I have a recursive call to a method that throws a stack overflow exception. The first call is surrounded by a try catch block but the exception is not caught. Does ...
- Modified
- 28 Oct at 17:38
How using try catch for exception handling is best practice
How using try catch for exception handling is best practice while maintaining my colleague's code from even someone who claims to be a senior developer, I often see the following code: or sometimes th...
If an Exception happens within a using statement does the object still get disposed?
If an Exception happens within a using statement does the object still get disposed? If an Exception happens within a using statement does the object still get disposed? The reason why I'm asking is b...
What is the difference between the 3 catch block variants in C# ( 'Catch', 'Catch (Exception)', and 'Catch(Exception e)' )?
What is the difference between the 3 catch block variants in C# ( 'Catch', 'Catch (Exception)', and 'Catch(Exception e)' )? In C#, what is the difference Between 'Catch', 'Catch (Exception)', and 'Cat...
- Modified
- 5 Dec at 03:57
Try/Finally block vs calling dispose?
Try/Finally block vs calling dispose? Is there any difference between these two code samples and if not, why does `using` exist? vs: I mean in the second example you really shoul
- Modified
- 3 Nov at 17:59
Return in try & catch versus return in finally?
Return in try & catch versus return in finally? Is either one of these risky? Is one better? Or is it one of those things you print out and throw a dart at to decide? I want to do this now that I unde...
How to do try catch and finally statements in TypeScript?
How to do try catch and finally statements in TypeScript? I have error in my project, and I need to handle this by using , and . I can use this in JavaScript but not in Typescript. When I put as argum...
- Modified
- 22 Sep at 12:40
Main method code entirely inside try/catch: Is it bad practice?
Main method code entirely inside try/catch: Is it bad practice? Usually I put all of my Main method code inside of a try/catch block like so: I do this just in case any exceptions manage to slip out o...
- Modified
- 28 Jan at 11:20