Draconian Error Handling
An error policy where a parser must stop and report failure at the first malformed input instead of trying to recover. It is the strict opposite of the robustness principle.
Also known as: Draconian Error Handling Policy, Strict Parsing, Tag Soup, Fatal Error on Malformed Input
Category: Software Development
Tags: software-development, software-design, standards, web, reliability, validation, compatibility
Explanation
Draconian error handling is the rule that XML made famous: when a document isn't well-formed, the parser has to stop. No guessing, no repair, no partial result. One missing end tag or one unescaped ampersand, and the whole document is rejected.
**Where it comes from**:
The designers of XML had seen what lenient parsing did to HTML. Browsers accepted almost anything, authors wrote almost anything, and every browser guessed differently. The result was "tag soup": pages that only worked in the browser they were tested in. For XML, the working group decided in 1997 to do the opposite and made well-formedness errors fatal.
**The argument for**:
- Errors get caught where they're created, by the author, not by each reader
- Every parser agrees on every document. There's no room for different interpretations
- Parsers stay small and simple, because they don't contain recovery logic
- No silent corruption: you never process data that means something else than you think
**The argument against**:
- **Users pay for the mistakes of authors**: XHTML showed this. A single encoding glitch in a comment or an ad turned the whole page into an error message
- **It assumes that producers are reliable**: On the open web, with content assembled from many sources, they aren't
- **Competition punishes strictness**: When one tool shows the content and another shows an error, users pick the first one
**How it ended on the web**:
The web didn't move to strict XHTML. HTML5 took a third path: it specifies the error recovery itself, in full detail. Every browser has to recover from each kind of broken markup in exactly the same way. That's liberal acceptance without the ambiguity.
**The three options for malformed input**:
1. **Guess** (the naive reading of Postel's Law): Everyone recovers their own way. Implementations drift apart
2. **Reject** (draconian): Simple and unambiguous, and harsh for the end user
3. **Specify the recovery**: The most work, and the only one that scales when you don't control the producers
**When draconian is the right choice**:
- Machine-to-machine formats, where the producer is a program that someone can fix
- Configuration files and source code
- Security-sensitive input
- New formats: start strict. You can't tighten later
Related Concepts
← Back to all concepts