mirror of
https://github.com/fluffos/fluffos
synced 2026-08-12 18:26:06 -04:00
* docs: document the real rules for throw(), add a structured catch() example throw.md called throw() "forces an error to occur in an object" and treated the catch() requirement as a style suggestion. Neither matches what f_throw()/throw_error() do. Rewrite the page around the rules the driver actually implements, each verified against a running driver: - An uncaught throw() raises *Throw with no catch. and discards the value. This is a requirement, not advice. - Any type round-trips through catch() verbatim, not just strings. - throw(0) is indistinguishable from success, since catch() returns 0 for "no error". This was documented only on catch.md. - A thrown value skips the error machinery entirely: no traceback, no debug log, no error_handler() apply, and no leading '*'. That '*' is the discriminator handling code keys on, and it appeared on neither page. - Only the innermost catch() sees it; rethrow to propagate further. - It crosses ordinary calls (call_other, inherited functions, evaluate(), filter/sort_array callbacks, a create() running under load_object) but cannot escape a call the driver starts itself (call_out, input_to, driver applies), which each begin a fresh chain with no catch above them. The old example's `return;` after throw() was unreachable, and it concatenated a caught driver error into a new message, burying the '*' mid-string so callers testing err[0] would stop recognising it. Both fixed. catch.md gains a third example that throws a class: its existing two both use string errors and imply catch() only ever yields text. Written with dot accessors and named-argument new(), matching the ordering in lpc/types/classes.md. Chinese translations updated to match. The zh-CN catch.md description said throw() returns a non-zero value, narrower than "any value except 0" and the exact claim the new example rests on; corrected. Every example block was extracted from the markdown and compiled by the driver, Chinese comments and strings included. Both locales build clean. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014JuB4acdTho1rmAL7PwvS1 * docs: fix the rethrow example forging a driver-error '*' Review feedback on the rethrow example was right, and the bug is worse than a style nit: the example contradicted the rule its own page teaches. It stripped a leading '*' from the caught value and then unconditionally put one back, so anything that was not a driver error came back disguised as one. Verified against the driver: mudlib string -> "*move_or_fail(): took too long\n" (forged '*') structured -> "*Bad type argument to +. Had string and array\n" The second case is worse still: concatenating a string onto a thrown array destroys the original failure and replaces it with a type error raised inside the handler. Re-add the '*' only when it was there to begin with, add context without it for a non-driver string, and pass a non-string value through untouched. Now: driver error -> "*move_or_fail(): bad thing\n" mudlib string -> "move_or_fail(): took too long\n" structured -> ({ "insufficient_funds", 7 }) Also quote the uncaught-throw error as the full string it actually is, "*Throw with no catch.\n", matching the two example strings shown a few lines above that spell out their trailing newline. And drop the "any value, except 0" phrasing on catch.md, which reads as though throwing 0 were rejected. It is not rejected, merely undetectable, since catch() already returns 0 for "no error". The zh-CN page inherited the same ambiguity from the English; both now say so explicitly. All four example blocks recompiled from the markdown; both locales build clean. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014JuB4acdTho1rmAL7PwvS1 --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| arrays | ||
| async | ||
| buffers | ||
| calls | ||
| contrib | ||
| crypto | ||
| db | ||
| ed | ||
| external | ||
| ffi | ||
| filesystem | ||
| floats | ||
| functions | ||
| general | ||
| interactive | ||
| internals | ||
| jsbridge | ||
| mappings | ||
| mudlib | ||
| numbers | ||
| objects | ||
| parsing | ||
| pcre | ||
| sockets | ||
| strings | ||
| system | ||