Exception Handling
Documentation menu
Markdown can arrive from a file, a database or a form. These notes describe how to keep a rendering failure contained and how to report it to the person who can fix the source.
Failure modes
- A block opens without being closed, so the parser consumes more text than intended.
- An include points at a file that does not exist or has moved.
- An option value is not valid for the extension that reads it.
- A media block cannot read the metadata it needs.
Contain the failure
Render in a context that can catch an exception without taking down the host. Log the document identifier and the position of the failure if the parser exposes one. Do not log the entire document when it may contain private content.
Help the author
A parser error is rarely useful on its own. Show a short message that names the block and the likely fix, and keep the source available for editing. A preview endpoint that renders one document is a good place to surface these messages.