tagged [exception]

Will main thread catch exception thrown by another thread?

Will main thread catch exception thrown by another thread? If I have code like this: Will the exception thrown by thread `t` be caught in the catch block?

10 Feb at 21:16

Caught exception is null itself !

Caught exception is null itself ! I have an ASP.NET applications. Everything was fine, but recently I get exceptions that are null themselves: Sometimes `ex` is `null` itself ! Any idea?

12 Apr at 11:35

WebKit.Net and OpenWebKitSharp Error: Failed to initialize activation context

WebKit.Net and OpenWebKitSharp Error: Failed to initialize activation context I am using both/either WebKit.Net and OpenWebKitSharp. However, as soon as I try to instantiate the WebKitBrowser, I get a...

How to catch all exceptions in c# using try and catch?

How to catch all exceptions in c# using try and catch? I want to write some try and catch that catch any type or exception, is this code is enough (that's the way to do in Java)? Or should it be ?

10 May at 04:52

How to rethrow the inner exception of a TargetInvocationException without losing the stack trace

How to rethrow the inner exception of a TargetInvocationException without losing the stack trace I have many methods which are calling using `Delegate.DynamicInvoke`. Some of these methods make databa...

Identifying Exception Type in a handler Catch Block

Identifying Exception Type in a handler Catch Block I have created custom exception class In my application how can I find out if it is my custom exception or not? ``` try { ... } catch (Exception err...

2 Mar at 15:59

XDocument.Load(XmlReader) Possible Exceptions

XDocument.Load(XmlReader) Possible Exceptions What are the possible exceptions that can be thrown when `XDocument.Load(XmlReader)` is called? It is hard to follow best practices (i.e. avoiding generic...

1 Aug at 21:49

How to throw std::exceptions with variable messages?

How to throw std::exceptions with variable messages? This is an example of what I often do when I want to add some information to an exception: ``` std::stringstream errMsg; errMsg

25 Jul at 02:0

Catch exception and continue try block in Python

Catch exception and continue try block in Python Can I return to executing the `try` block after exception occurs? For example: vs.

27 Mar at 22:10

How can I catch exceptions with RestSharp

How can I catch exceptions with RestSharp I am working on a project with RestSharp. Over time I discovered several exceptions that RestResponse class can throw, most of which I have to handle so my ap...

10 Jan at 04:53

Try/catch blocks inside constructors

Try/catch blocks inside constructors Is it a bad programming practice to have try/catch blocks inside constructors? Or does it make no difference as long as our programs handle typeinitializer excepti...

What happens if a finally block throws an exception?

What happens if a finally block throws an exception? If a finally block throws an exception, what happens? Specifically, what happens if the exception is thrown midway through a finally block. Do the...

18 Jan at 09:0

Get exception description and stack trace which caused an exception, all as a string

Get exception description and stack trace which caused an exception, all as a string How to convert a caught `Exception` (its description and stack trace) into a `str` for external use?

What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it?

What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? What does `ArrayIndexOutOfBoundsException` mean and how do I get rid of it? Here is a code sample that triggers the exce...

In Python, how does one catch warnings as if they were exceptions?

In Python, how does one catch warnings as if they were exceptions? A third-party library (written in C) that I use in my python code is issuing warnings. I want to be able to use the `try` `except` sy...

20 Jun at 09:38

Exception shows developer's path instead of servers

Exception shows developer's path instead of servers When an exception occurs with any ASP.NET project (possibly any .net app) the stack trace will show the path on the developer's machine, even when i...

28 Aug at 15:22

Can Exception stack trace ever be null?

Can Exception stack trace ever be null? I found out that if I am catching an Exception e, e.innerException could possibly be null. Is it also possible that e.StackTrace could also be null in any possi...

10 Feb at 21:58

Where Should Exception Messages be Stored

Where Should Exception Messages be Stored Since I can't use Microsoft as an example for best practice since their exception messages are stored in resource files out of necessity, I am forced to ask w...

23 Jan at 21:23

Casting an out-of-range number to an enum in C# does not produce an exception

Casting an out-of-range number to an enum in C# does not produce an exception The following code does not produce an exception but instead passes the value 4 to tst. Can anyone explain the reason behi...

22 Feb at 15:24

Can I execute multiple Catch blocks?

Can I execute multiple Catch blocks? This is a bit abstract, but is there any possible way to throw an exception and have it enter multiple catch blocks? For example, if it matches a specific exceptio...

14 Feb at 21:42

How to find first chance exceptions from output window

How to find first chance exceptions from output window I'm getting first chance exceptions in my output window in debug mode. How do I find where they're coming from? Do I have to put a breakpoint in ...

31 May at 12:12

Checking if a file is in use without try catch?

Checking if a file is in use without try catch? Is there a way I can check if a file is in use or is not opened by other process without just trying to open it and catching an exception? Is there no s...

13 Mar at 12:25

Where can I find a list of SocketErrorCode and NativeErrorCode thrown by SocketException?

Where can I find a list of SocketErrorCode and NativeErrorCode thrown by SocketException? A SocketException has a SocketErrorCode and NativeErrorCode. I would like to find a list where these codes (or...

8 Dec at 22:12

In C#, how do I know which exceptions to catch?

In C#, how do I know which exceptions to catch? I've gotten in the habit of using a general catch statement and I handle those exceptions in a general manner. Is this bad practice? If so, how do I kno...

28 Apr at 13:57

How can a unit test confirm an exception has been thrown

How can a unit test confirm an exception has been thrown Im writing a unit test for a c# class, One of my tests should cause the method to throw an exception when the data is added. How can i use my u...

5 Oct at 16:16