Throwing and Catching Exceptions in Functions
Learn about exception handling, utilize built-in exception types and implement strategies like rethrowing and the tester-doer pattern.
We should catch and handle an exception if we have enough information to mitigate the issue. If we do not, then we should allow the exception to pass up through the call stack to a higher level.
Understanding usage errors and execution errors
Usage errors are when a programmer misuses a function, typically by passing invalid values as parameters. A programmer could avoid them by changing their code to pass valid values. When some programmers first learn C# and .NET, they sometimes think exceptions can always be avoided because they assume all errors are usage errors. Usage errors should all be fixed before production runtime.
Get hands-on with 1400+ tech skills courses.