tagged [exception]

System.Exception.Data Property

System.Exception.Data Property The System.Exception class (actually any exception) has Data property which is almost always empty. While throwing exceptions, should this field be of any use? Or does i...

1 May at 10:31

What are checked exceptions in Java/C#?

What are checked exceptions in Java/C#? I am a C# developer doing occasional coding in Java. Can someone explain in simple terms what are checked exceptions in Java and why is it needed? Haven't come ...

21 Feb at 03:45

Correct way to try/except using Python requests module?

Correct way to try/except using Python requests module? Is this correct? Is there a better way to structure this? Will this cover all my bases?

Best practices: throwing exceptions from properties

Best practices: throwing exceptions from properties When is it appropriate to throw an exception from within a property getter or setter? When is it not appropriate? Why? Links to external documents o...

28 Sep at 18:1

Throwing ArgumentNullException in constructor?

Throwing ArgumentNullException in constructor? For a constructor with a single parameter, is it OK to throw an ArgumentNullException inside the constructor if the parameter is null/empty? OR, should i...

System.Runtime.InteropServices.COMException (0x80040154):

System.Runtime.InteropServices.COMException (0x80040154): I'm getting an exception in a c# project: > System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for com...

2 Dec at 15:37

Pass object (List<string>) as part of Exception

Pass object (List) as part of Exception I am constructing a list of strings and then want to throw an exception and let the UI handle the list and create the error message for the user. Is there a way...

25 Jun at 17:2

Which built-in .NET exceptions can I throw from my application?

Which built-in .NET exceptions can I throw from my application? If I need to throw an exception from within my application which of the built-in .NET exception classes can I use? Are they all fair gam...

5 Dec at 04:23

Parallel.Foreach exceptions and cancel

Parallel.Foreach exceptions and cancel I have tried to find out how exceptions and cancel work for `Parallel.Foreach`. All examples seems to deal with Tasks. What happens on an exception in `Parallel....

How Can I Force Execution to the Catch Block?

How Can I Force Execution to the Catch Block? I am wondering can `try..catch` force execution to go into the `catch` and run code in there? here example code:

16 Feb at 15:14

await with null propagation System.NullReferenceException

await with null propagation System.NullReferenceException I have the following code: `Visual Studio` highlights this code, saying 'Possible NullReferenceException' by the way, without `await` `Visual ...

C# "Using" Syntax

C# "Using" Syntax Does the using catch the exception or throw it? i.e. If the streamreader throws an exception is it caught by using or thrown so the calling function can handle it?

11 Apr at 21:52

Can you catch a native exception in C# code?

Can you catch a native exception in C# code? In C# code can you catch a native exception thrown from deep in some unmanaged library? If so do you need to do anything differently to catch it or does a ...

29 Sep at 20:41

Do I need to create my own InvalidArgumentException.. I couldn't find any builtin type in c#

Do I need to create my own InvalidArgumentException.. I couldn't find any builtin type in c# Do I need to create my own InvalidArgumentException.. I couldn't find any built-in types in c#... Is there ...

26 Jan at 20:42

How to handle general exceptions in Asp.Net MVC?

How to handle general exceptions in Asp.Net MVC? I want to transfer all unhandled exceptions to an error page in Asp.Net MVC. What is the way to handle the unhandled exceptions in Asp.net MVC? Is ther...

6 Mar at 11:36

Why does this "finally" execute?

Why does this "finally" execute? If you run the code below it actually executes the finally after every call to the goto: Why?

12 May at 20:18

Is it a good practice to throw an exception on Validate() methods or better to return bool value?

Is it a good practice to throw an exception on Validate() methods or better to return bool value? Is it recommended or not to throw exceptions from Validation methods like: Apart from this : Is there ...

29 May at 11:56

Catch Application Exceptions in a Windows Forms Application

Catch Application Exceptions in a Windows Forms Application Is there anyway to catch expections that is thrown by anywhere in the code? I would like to catch exceptions and handle them in a similar ma...

7 Sep at 12:42

Why does Dictionary.ContainsKey throw ArgumentNullException?

Why does Dictionary.ContainsKey throw ArgumentNullException? The documentation states that `bool Dictionary.ContainsKey(TKey key)` throws an exception in case a null key is passed. Could anyone give a...

6 Dec at 15:45

Try-Catch with fluent expressions

Try-Catch with fluent expressions This LINQ query expression fails with Win32Exception "": And this fails with IOException "": What is the best way to filter out inaccessible objects and avoid excepti...

WPF global exception handler

WPF global exception handler Sometimes, under not reproducible circumstances, my WPF application crashes without any message. The application simply close instantly. Where is the best place to impleme...

15 Jun at 11:50

Why doesn't list have safe "get" method like dictionary?

Why doesn't list have safe "get" method like dictionary? Why doesn't list have a safe "get" method like dictionary?

How can I catch all types of exceptions in one catch block?

How can I catch all types of exceptions in one catch block? In C++, I'm trying to catch all types of exceptions in one catch (like `catch(Exception)` in C#). How is it done? And what's more, how can o...

31 Oct at 14:15

Will Try / Finally (without the Catch) bubble the exception?

Will Try / Finally (without the Catch) bubble the exception? I am almost positive that the answer is YES. If I use a Try Finally block but do not use a Catch block then any exceptions WILL bubble. Cor...

29 Nov at 18:51

pretty printing exceptions in C#

pretty printing exceptions in C# Is there any API that allows to prints all the exception-related info (stack trace, inner etc...)? Just like when the exception is thrown - all the data is printed to ...

15 Dec at 13:52