Troubleshooting and Debugging

No software product is perfect, and the harsh truth is that no matter how much effort you put into designing and testing your code, there is always a very good chance that you missed some edge case that will cause your application to fail. If you can't win the game, you need to change the rules. Instead, make sure that, even if your application fails with an error, it will know how to recover and give you as much information as it can so that you can reproduce the scenario and solve the problem.

In this chapter, you will learn how you can protect your API from unhandled exceptions, and how you can return meaningful error responses to your API client that will later allow you to decipher what the problem was. You will also learn how to add logging and diagnostics to your code, so that problem investigation will become easier.

In this chapter, we will cover the following topics:

  • Adding logging to your application
  • Enabling diagnostics with Application Insights
  • Responding gracefully in cases of errors and exceptions
  • Making your APIs discoverable, and self-documenting with the OpenAPI standard (Swagger)

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.17.18