Error Handling in C# with Exceptions

Error Handling in C# with Exceptions

English | MP4 | AVC 1280×720 | AAC 44KHz 2ch | 1h 37m | 270 MB

Understanding and using exceptions is crucial to creating readable code that responds correctly to errors at runtime. This course will teach you how to handle errors in C# applications by throwing, catching, filtering, and customizing exceptions.

At the core of handling errors in C# code is a thorough knowledge of exception handling. In this course, Error Handling in C# with Exceptions, you’ll learn how to write code that can detect and respond to runtime errors. First, you’ll learn why exceptions are used to represent errors in C# and how they are organized into class hierarchies. Next, you’ll explore how to throw, catch, filter, rethrow, and wrap exceptions. Finally, you’ll discover how to define, throw, and catch your own customized exception classes and also write unit tests for exception throwing code. When you’re finished with this course, you’ll have a thorough knowledge of C# exceptions that will help you to create production-ready C# applications that detect and respond to runtime errors.

Table of Contents

Course Overview
1 Course Overview

Understanding the Importance of Error Handling
2 Introduction
3 Course Overview
4 Why Handle Errors
5 Error Handling Using Error Codes
6 Why Exceptions
7 What Is an Exception
8 Summary

Understanding the Exception Class Hierarchy
9 Introduction
10 What Does an Exception Represent
11 The Exception Class Hierarchy
12 The System.Exception Base Class
13 Commonly Used System.Exception Constructors
14 System.ApplicationException Guidelines
15 Commonly Encountered Exceptions
16 Summary

Getting Started with Exceptions
17 Introduction
18 Understanding Exception Handling
19 Introducing the Try Statement
20 Demo Code Overview
21 Causing an Exception
22 Understanding the Stack Trace
23 Creating and Throwing an Exception
24 Getting Started with Exception Catching
25 Exception Handling Good Practices
26 Summary

Catching Throwing and Rethrowing Exceptions
27 Introduction
28 Throwing Exceptions from Expressions
29 Catching Different Exception Types with Multiple Catch Blocks
30 Understanding the Finally Block
31 Rethrowing Exceptions and Preserving the Stack Trace
32 Catching and Wrapping Exceptions
33 Filtering Catch Blocks with Exception Filters
34 Global Unhandled Exception Handling
35 Summary

Creating and Using Custom Exceptions
36 Introduction
37 Understanding Custom Exceptions
38 Defining a Custom CalculationException
39 Defining a Custom CalculationOperationNotSupportedException
40 Using Custom Exception Classes
41 Summary

Writing Automated Tests for Exception Throwing Code
42 Introduction
43 Testing Exceptions with MSTest V2
44 Testing Exceptions with NUnit
45 Testing Exceptions with xUnit.net
46 Summary Resources and Further Learning