Exception handling

Exception handling is an integral part of running any application. Below you will find all the relevant information regarding the subject.

Hello world!

The basics

Learn about the concept of exception handling and how it differs from using error codes.

Start here

Exception classes

Learn about exception classes and how they are used in exception handling.

Read the article

Best practices

All the best practices you'll need to maximize effectiveness with exception handling in .NET.

Do not catch exceptions

Best practice number 1: do not catch exceptions. Let's start by defining what "handled" means when talking about exceptions.

Read it

Use argument exceptions

Learn about why it's crucial to use argument exceptions when coding a robust application.

Read it

Fulfil the contract or die trying

If you want to avoid side effects in your application, always make sure the method can deliver what it promised.

Read it

Always reproduce errors

If you cannot reproduce an error, you are most likely writing a workaround instead of a real fix. Be careful.

Read it

Try to include context in the exception message

Reproducing bugs can be hard. Try to write informative exception messages to make the process easier.

Read it

Avoid "throw ex;" in catch blocks

`throw ex;` in catch blocks isn't doing what you think.

Read it