Skip to content

docs: Document exception inheritance and sealed exception hierarchies#706

Draft
marcelomendoncasoares wants to merge 2 commits into
serverpod:mainfrom
marcelomendoncasoares:docs/exception-inheritance
Draft

docs: Document exception inheritance and sealed exception hierarchies#706
marcelomendoncasoares wants to merge 2 commits into
serverpod:mainfrom
marcelomendoncasoares:docs/exception-inheritance

Conversation

@marcelomendoncasoares

Copy link
Copy Markdown
Collaborator

Summary

Exception models support extends and sealed, which is what makes an exhaustive switch over server failures possible in the app. The error handling page only covered flat exceptions, and the model reference listed both keywords as class-only.

Changes

  • Add an "Exception hierarchies" section to the error handling page.
  • Show extends and sealed on exception model definitions.
  • Add an endpoint that throws the concrete child exceptions and an app that catches the base type and switches over the subtypes exhaustively.
  • Explain what a sealed base buys the app when a new exception is added later.
  • Cover hierarchies in shared packages, including the rule that every subtype has to stay in the package declaring the base.
  • State the validation rule that exceptions and regular models cannot be mixed in one hierarchy.
  • Mark sealed as applicable to exceptions in the model reference, adjust the extends note, and link the error handling page from Related.

Reference

🤖 Generated with Claude Code

Use a noun-shaped heading like the neighbouring subsections, label the
model files with the code block title attribute instead of a comment,
link the inheritance page for extends and sealed, and tighten the closing
paragraphs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant