Skip to content

Resource · Guide or article

Exception Handling

A brief page on exception handling: why exceptions help, when to define custom ones and how to return errors from an API. A refresher for backend engineers asked how they structure error handling.

Reviewed

Open the original: Exception Handling (opens the original site in a new tab)

Practice this topicOpens the practice interviewer in System design mode; choose a question there.

Add to a roadmap

Keep this resource with a roadmap you follow. It appears as your own extra resource; the roadmap's steps don't change and it doesn't count toward your tracked steps.

Source content: English

Almost all language platforms offer a construct of exception or equivalent to handle error scenarios. The underlying platform, used libraries or the authored code can "throw" exceptions to initiate an error flow. Some of the advantages of using exceptions are -

PrepKit overview

PrepKit editors wrote and reviewed this overview from the source repository. It is not text from the resource itself.

Suited to
The source does not state a level
Format
Article

What it covers

  • Reasons to define custom exceptions, such as domain errors like InvalidCustomerException and wrapping a MongoWriteException in a stack-agnostic DatabaseWriteException
  • A sample hierarchy with a BaseException carrying ActionCode and ResultCode, split into system and business exceptions
  • Returning API errors in the RFC 7807 problem details format

How to use it

PrepKit study advice, not a claim made by the source.

Sketch the exception hierarchy for a service you wrote, separating technical failures from business rule violations. Be ready to explain why you wrap a driver exception instead of letting it reach callers.

Scope and limitations

Short team guidance with a .NET and ASP.NET Core focus; most detail sits behind Microsoft documentation links, and the hierarchy diagram is an external image.

Access and format

Web page on microsoft.github.io from Microsoft's Code-With Engineering Playbook. English, free, CC BY 4.0.

Reviewed by PrepKit on Oct 2, 2026. Listing source commit: 016770e43d8a

Evidence behind this overview
  • docs/design/exception-handling.md

Pages that include this

Get the PrepKit newsletter

Optional. You don't need it to use PrepKit.

How we handle your email