Skip to main content
There are no custom error classes in Fairyfly. You get QuickJS’s built-ins — Error, TypeError, SyntaxError, RangeError — plus a handful of APIs that reject with plain strings. Permission failures are ordinary Error objects with extra properties: name is PermissionDenied and code is PERMISSION_DENIED. There is no PermissionDenied constructor, so check e.code rather than using instanceof.

Uncaught errors

An exception that escapes your script prints the message and stack to stderr, then the process exits 1:
Note the doubled Error: Error: prefix, the at <eval> frame carrying file:line:column, and the blank line before the shell prompt. try / catch works as usual — for the APIs listed below.

What throws (and what doesn’t)

Sync fs swallows I/O errors today. A missing file, a bad directory, an unreadable path — all return undefined with no exception. Always check fs.exists() first, or use the Promise variants, which report the real error:
Permission denial is separate from I/O failure — it throws even for sync calls:

Unhandled promise rejections are silent

In script context a rejected Promise with no handler prints nothing and the process exits 0:
Always attach a .catch, or await inside a try. In an HTTP handler the runtime does catch it — a rejected handler Promise becomes a 500 response.

fetch rejects with strings

Failed fetches reject with a string, not an Error, so e.message is undefined:
A diagnostic line also goes to stderr:
Permission denial is different:
  • The initial fetch check throws an Error named PermissionDenied with code: "PERMISSION_DENIED" before the request is submitted. In an async function that surfaces as a rejected promise.
  • A denial on a redirect hop rejects the fetch promise with a plain string: PermissionDenied: fetch requires --allow-net. That string has no .message and no .code.

Server-side failures

A permission denial is not a handler failure: http.serve checks its bind scope when the server starts, and fs / fetch denials inside a handler are thrown as normal JavaScript exceptions (uncaught → 500).

Exit codes

Message catalogue

Strings you’ll see in practice — useful for assertions in tests:

Gotchas

  • e.message is undefined for ordinary fetch rejections and redirect permission denials — check typeof e. Initial permission errors are real Error objects.
  • A successful fs.*Async call hangs the process afterwards (it prints, then never exits) — Known issue, see fs.
  • Sync fs I/O failures are silent; don’t write try/catch around them expecting an exception. Permission denials do throw.
  • process.env never throws; a disallowed variable is just undefined.
  • There is no PermissionDenied constructor — check e.code or e.name.
  • FFI denials are PermissionDenied too; the message is bare (ffi.read requires --allow-ffi) because there is no scope.
  • There is no process.on("uncaughtException") and no unhandledRejection hook — there’s nothing to subscribe to.
  • Errors thrown inside a Worker surface on the parent via onerror.

See also