Skip to content

EN Runtime Errors and Logging

Andrewkydev edited this page Aug 25, 2026 · 1 revision

Runtime Errors and Logging

Русский: RU-Runtime-Errors-and-Logging

App.Start(ctx):

  1. rejects concurrent starts;
  2. freezes the plugin snapshot and loads settings;
  3. applies configured migrations;
  4. starts plugins;
  5. passes event subscriptions and command prefixes to adapters;
  6. starts adapters concurrently;
  7. retries a failed adapter with a 1–30 second backoff;
  8. stops plugins in reverse order when canceled.

A handler panic is converted into a typed internal error and logged with its stack trace. The common recovery mechanism does not cover panics inside platform goroutines.

Error codes

invalid_argument, not_found, unauthorized, forbidden, conflict, unavailable, rate_limited, unsupported, canceled, deadline_exceeded, internal.

Use errors.CodeOf, IsCode, IsRetryable, and PublicMessage. Do not return a wrapped cause to an external client.

Logging

stream := logging.NewStream(256)
logger := logging.New(logging.Config{
	Level: slog.LevelInfo,
	Format: logging.FormatJSON,
	Stream: stream,
})
app.SetLogger(logger)

Each handler receives an event-scoped logger through ctx.Log().

runtime.Scheduler runs fixed-interval jobs until cancellation. runtime.WorkerPool limits concurrency. Neither recovers from a job panic; recovery must be implemented inside the task.

Clone this wiki locally