diff --git a/posts/2019-02-24-exceptions_are_bugs_not_business_logic.md b/posts/2019-02-24-exceptions_are_bugs_not_business_logic.md new file mode 100644 index 000000000..9c732df99 --- /dev/null +++ b/posts/2019-02-24-exceptions_are_bugs_not_business_logic.md @@ -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); +} +```