O'Reilly logo

Mastering ASP.NET Web API by Malendra Hurbuns, Mithun Pattankar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Exception management in a MyWallet project

Any web API project is not an application in itself. It is built so that popular frontends, either web or desktop, can consume it. It becomes essential for web APIs to handle any unexpected events (unhandled exceptions) or any business exception gracefully.

If unexpected events (unhandled or business-related) occur, then they should be logged and the appropriate response should be sent back so that clients can be made aware of it.

To achieve this, we require the following classes:

  • WebAPIError: It acts as a response object to be used by clients.
  • WebAPIException: It is a custom exception class for business or unhandled exceptions. It contains exception details, along with the status code.
  • WebAPIExceptionFilter ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required