Learn how you can use a global exception handler in Web API to handle all previously unhandled exceptions.
- [Instructor] Now we've looked at handling exceptions…from our controllers using filters…and also logging them with exception loggers.…There's one final way we can handle exceptions in Web API…and that's with Global Exception Handlers.…Just like the exception logger,…we're only going to have one of these…for the entire application,…so it needs to be generic enough…to handle any unhandled exception…that bubbles up to that level.…Let's create a Global Exception Handler…that will display an exception and its stack trace…when we're running in the debug configuration.…
And we'll just return a simple, something went wrong…type of message when we're not.…That way we don't accidentally reveal too much…about the inner workings of our application…in a production environment,…but we still get the stack trace…and other exception details when we're in a…development or testing environment…and then we can use those to help us debug problems…with our application.…We'll start by create a new class…inside of the ExceptionHandlers folder.…
AuthorJonathan "J." Tower
- Convention-based routing
- Binding your code to an HTTP request
- Validating models
- Using attributes to route requests
- Customizing attribute routes
- Data serialization and model binding
- Error handling
- Using exception filters and exception loggers
- API documentation and testing
- Securing your API
Skill Level Beginner
ASP.NET MVC: HTTP Request Life Cyclewith Janan Siam2h 15m Advanced
1. Controllers and Actions
3. Data Serialization and Model Binding
4. Error Handling
5. API Documentation and Testing
Next steps1m 38s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.