Exception handling

Exception handling is an integral part of running any application.

Below you will find all the relevant information regarding the subject. Please do not hesitate to take advantage of our awesome forum in case you are still left with any comments or questions.

Hello world!

Getting started

The basics

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

Read the article

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.

Learn more

Use argument exceptions

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

Learn more

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.

Learn more

Always reproduce errors

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

Learn more

Try to include context in the exception message

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

Learn more

Avoid "throw ex;" in catch blocks

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

Learn more