AponiaJSDocs
API reference

Error codes

Diagnose every AponiaError code exposed by the public contract.

AponiaError provides a stable code, a human-readable message, and frozen structured details.

CodeCauseTypical correction
MODULE_CYCLEA module import path returns to a module already being compiled.Break the import cycle and extract a shared boundary.
DUPLICATE_MODULEDifferent definitions claim the same module ID or stable dynamic identity.Use one definition or a distinct dynamic-module key.
DUPLICATE_PROVIDEROne module declares the same provider or controller token twice.Remove the duplicate registration.
INVALID_EXPORTA module exports a token it cannot resolve.Provide it locally or import a module that exports it.
AMBIGUOUS_PROVIDERMultiple imported source modules export the same token.Export distinct tokens or restructure imports.
MISSING_PROVIDERA dependency is not visible from the requesting module.Add a provider, import its module, and export the token.
PROVIDER_CYCLEProvider resolution returns to a provider being constructed.Remove the constructor/factory cycle.
INVALID_CONTROLLERMissing decorator metadata, a non-callable route handler, or a controller factory that returned a non-Elysia value.Add @Controller(), use callable methods, or return an Elysia plugin.
INVALID_MODULEA class root/import is missing @Module().Decorate it or pass a low-level definition.
INVALID_VALIDATION_MODELA route slot received a class that is not decorated with @Validation().Decorate the model class or pass the validator directly.
INVALID_NATIVE_APPLICATIONconfigureNative returned a different Elysia object.Return the received instance after chaining methods.
APPLICATION_NOT_LISTENINGgetUrl() ran before listen().Listen first or avoid URL access in in-process tests.
UNSUPPORTED_CONTROLLERThe Elysia platform received a controller descriptor owned by another platform kind.Use a decorated controller or an Elysia controller descriptor.
INVALID_WEBSOCKET_GATEWAYA gateway has no message handlers, or a @WebSocketServer() property target is invalid.Add a @SubscribeMessage() handler and annotate a writable property.
DUPLICATE_WEBSOCKET_GATEWAYTwo gateways claim the same upgrade path.Give each gateway a distinct path.
DUPLICATE_WEBSOCKET_HANDLEROne gateway subscribes to the same event twice.Keep one handler per event name.
INVALID_WEBSOCKET_MESSAGEA client frame is not a valid { event, data } envelope.Send the documented envelope.
UNKNOWN_WEBSOCKET_EVENTNo handler is registered for the received event.Subscribe the event or correct the client.
WEBSOCKET_HANDLER_ERRORA message handler threw.Handle the failure inside the gateway.

Inspect an error

import { AponiaError } from "@aponiajs/common";
import { AponiaFactory } from "@aponiajs/platform-elysia";
import { AppModule } from "./app.module.ts";

try {
  await AponiaFactory.create(AppModule);
} catch (error) {
  if (error instanceof AponiaError) {
    console.error(error.code, error.details);
  }
  throw error;
}

These errors describe framework graph and lifecycle validation. Route input validation is performed by Elysia and answers 422; for failures an application throws deliberately, use the Problem Details helpers in HTTP errors. Assert the code rather than the message, which is not part of the contract.

Graph errors through MISSING_PROVIDER are raised while the module graph compiles. Provider cycles are detected while singletons initialize, and controller, gateway, or platform diagnostics are raised while routes and sockets mount. All occur during AponiaFactory.create() or createNative(), before the application can listen.

The three message-level WebSocket codes are the exception: they are produced after the application is listening and are returned to the client inside an exception envelope rather than thrown.

On this page