dream: error-handling middleware (dream-catch) + status reason phrases + 15 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 48s

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-07 15:03:17 +00:00
parent 078872728e
commit 17ef5f50b3
4 changed files with 142 additions and 2 deletions

View File

@@ -92,6 +92,13 @@ with extensions + hardening below.
in this worktree every `sx-tree` *edit* tool (`sx_replace_node`,
`sx_replace_by_pattern`, `sx_insert_near`) raises a yojson `Expected string, got
null` error — only `sx_write_file` works, so edits rewrite the whole file.
- **2026-06-07 — Ext: error handling + status phrases** (`lib/dream/error.sx`, 15
tests, 282 total). `dream-status-text` / `dream-status-line` reason-phrase map (string
keys); `dream-status-page` renders a status page. `dream-catch` is a `guard`-based
middleware that turns a raised error into a 500 (`dream-catch-with on-error` for a
custom page receiving `(req e)`); normal responses pass through untouched, composes
around a router. (`guard` catches explicit `(error …)` raises; `e` stringifies to the
message.)
## Extensions (post-roadmap)
@@ -99,9 +106,9 @@ The five-types core is complete; these harden it toward a production HTTP front
- [x] **Router HTTP correctness**: 405 Method Not Allowed + `Allow` header; automatic
HEAD (serve the GET handler with an empty body).
- [ ] **Status reason phrases** + `dream-status-text`.
- [x] **Status reason phrases** + `dream-status-text` (`lib/dream/error.sx`).
- [ ] **CORS middleware** (`dream-cors`).
- [ ] **Error-handling middleware** (`dream-catch` / custom 404 + 500 templates).
- [x] **Error-handling middleware** (`dream-catch` / custom 500 templates; `guard`-based).
- [ ] **Signed session cookies** (the noted hardening — sign the sid).
- [ ] **JSON helpers** (build from dict; parse to dict).
- [ ] **Query/header convenience** (`dream-queries`, defaults).