Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions posts/2019-02-24-exceptions_are_bugs_not_business_logic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: "Exceptions are bugs, not business logic!"
date: 2019-02-24
listed: false
---

# Exceptions are bugs, not business logic!

# Magic values

## Masks the issue, unnecessary code, results in NullReferenceException.

# Ensure your catch handlers never throw.

# When is it appropriate to catch exceptions?

1. When wrapping the exceptions with another exception to give it more context.

```c#
try
{
ProcessOrder(orderId);
}
catch(Exception ex)
{
throw new OrderException("An exception occured trying to process the order", orderId, ex);
}
```