PrepZone Logo
PrepZone

Exception Hierarchy Design

Domain errors vs infrastructure failures — typed, not stringly.

Read these first

Why this matters

  • Checked vs unchecked — detailed pointwise breakdown in the section below.
  • Domain exceptions — detailed pointwise breakdown in the section below.
  • Error codes — detailed pointwise breakdown in the section below.
  • CampusOS payments — detailed pointwise breakdown in the section below.
  • Production Java structure interviewers expect in backend LLD.
Dependency direction
Controller / FacadeHTTP or API entry
Serviceuse cases, orchestration
Domainentities, rules, invariants
Repositorypersistence port
Dependencies point inward — domain never imports infrastructure.

Overview

Domain errors vs infrastructure failures — typed, not stringly. Study each section below in order — every list is interview-ready reference material.

Checked vs unchecked

Points to cover

  • Definition — what Checked vs unchecked means in one clear sentence
  • When to use — the force or smell that triggers this concept
  • CampusOS example — where this appears in parking, booking, or library modules
  • How to explain — pointwise bullets you can say aloud in an interview
  • Common mistake — what weak candidates do instead
  • Refactor move — one concrete change that improves the design

Domain exceptions

Points to cover

  • Definition — what Domain exceptions means in one clear sentence
  • When to use — the force or smell that triggers this concept
  • CampusOS example — where this appears in parking, booking, or library modules
  • How to explain — pointwise bullets you can say aloud in an interview
  • Common mistake — what weak candidates do instead
  • Refactor move — one concrete change that improves the design

Error codes

Points to cover

  • Definition — what Error codes means in one clear sentence
  • When to use — the force or smell that triggers this concept
  • CampusOS example — where this appears in parking, booking, or library modules
  • How to explain — pointwise bullets you can say aloud in an interview
  • Common mistake — what weak candidates do instead
  • Refactor move — one concrete change that improves the design

CampusOS payments

Points to cover

  • Definition — what CampusOS payments means in one clear sentence
  • When to use — the force or smell that triggers this concept
  • CampusOS example — where this appears in parking, booking, or library modules
  • How to explain — pointwise bullets you can say aloud in an interview
  • Common mistake — what weak candidates do instead
  • Refactor move — one concrete change that improves the design
Java
// CampusOS — apply "Checked vs unchecked" on paper first, then in code
public final class ExceptionDesignExample {
    // 1. Name entities from the problem statement
    // 2. Draw relationships before writing methods
    // 3. Introduce patterns only when a force appears
}

Quick recall

Everything you need if you only revisit this box.

  1. Checked vs unchecked — review this slice before mock interviews.
  2. Domain exceptions — review this slice before mock interviews.
  3. Error codes — review this slice before mock interviews.
  4. CampusOS payments — review this slice before mock interviews.

Test yourself

Answer these before moving on — recall is what makes it stick.