Pre-release Harn is pre-1.0 — the language, standard library, and CLI may change between releases. See the release notes

Runtime errors

ErrorDescription
undefinedVariable(name)Variable not found in any scope
undefinedBuiltin(name)No registered builtin or user function with this name
immutableAssignment(name)Attempted = on a let binding
typeMismatch(expected, got)Type assertion failed
returnValue(value?)Internal: used to implement return (not a user-facing error)
retryExhaustedAll retry attempts failed
thrownError(value)User-thrown error via throw

Most undefinedBuiltin errors are now caught statically by the cross-module typechecker (see Static cross-module resolution) — harn check and harn run refuse to start the VM when a file contains a call to a name that is not a builtin, local declaration, struct constructor, callable variable, or imported symbol. The runtime check remains as a backstop for cases where imports could not be resolved at check time.

Stack traces

Runtime errors include a full call stack trace showing the chain of function calls that led to the error. The stack trace lists each frame with its function name, source file, line number, and column:

Error: division by zero
  at divide (script.harn:3:5)
  at compute (script.harn:8:18)
  at default (script.harn:12:10)

Stack traces are captured at the point of the error before unwinding, so they accurately reflect the call chain at the time of failure.

Diagnostic code appendix

Runtime and static diagnostics use stable HARN-<category>-<number> codes. The generated diagnostics catalog is authoritative for the full registry; the language spec records runtime namespaces whose behavior affects portable programs.

Suspend/resume diagnostics (HARN-SUS-*)

CodeDescription
HARN-SUS-001suspend_agent was called on a worker that is not running.
HARN-SUS-002ResumeConditions validation failed.
HARN-SUS-003resume_agent was called on a live worker that is not suspended.
HARN-SUS-004A resume snapshot was missing, stale, unreadable, or version-incompatible.
HARN-SUS-005agent_await_resumption was invoked outside agent_loop structural handling.
HARN-SUS-006A concurrent resume changed the worker before resume completed.
HARN-SUS-007conditions.trigger could not be registered with the trigger dispatcher.
HARN-SUS-008A timeout fired or was configured with an unsupported on_timeout action.
HARN-SUS-009Resume input failed agent_loop input validation.
HARN-SUS-010A worker closed while suspended rejected a later resume.

OAuth diagnostics (HARN-OAU-*)

CodeDescription
HARN-OAU-001A persisted sink redacted an OAuth-shaped token (transcript / receipt / OTel / system reminder). The original value still flows through to the tool — redaction is display-only.
HARN-OAU-002std/oauth/client cannot refresh because no refresh_token is in storage (or the server rejected the refresh). Re-run start_authorization / device_flow.
HARN-OAU-005std/oauth/dynamic_registration rejected a candidate client metadata document under RFC 7591 §2.

Durable agent channels diagnostics (HARN-CHN-*)

CodeDescription
HARN-CHN-001pipeline: scope used outside any active pipeline context.
HARN-CHN-002Cross-tenant emit_channel without a grant, or org: scope (disabled in v1 until org grants are available).
HARN-CHN-003Malformed channel name, scope prefix, or scope id.
HARN-CHN-004Scope ambiguous — explicit options.session_id or options.pipeline_id conflicts with the active runtime context.
HARN-CHN-005Malformed batch config on a trigger_register call (missing count/window, non-positive count, unknown expire_action, or wrong-typed key).

Agent pool diagnostics (HARN-POL-*)

CodeDescription
HARN-POL-001A backpressure_queue(..., "fail_submitter") pool was full at submit time. Drop policies do not raise — they return a rejected task handle and emit a pool_drop audit on lifecycle.pool.audit.
HARN-POL-002A fail_fast() pool had no immediate capacity at submit time. The submitter receives the error synchronously; no task is enqueued.