Documents injecute 1.x · Migrating from 0.x
Skip to content

Errors ​

Every error injecute throws is an InjecuteError with a stable code, the resolution path (which service needed what), a docs link to the page below, and a message with a hint. Branch on code, not on message text.

CodeMeaning
INJECUTE_NOT_REGISTEREDNo service is registered under this key
INJECUTE_ALREADY_REGISTEREDThe key is already registered in this container or a parent
INJECUTE_CIRCULAR_DEPENDENCYServices depend on each other in a cycle
INJECUTE_NOTHING_TO_REPLACEA registration replaces a key that nothing is registered under
INJECUTE_NO_PREVIOUS_DEFINITIONA service depends on itself but there is nothing to decorate
INJECUTE_INVALID_FACTORYThe factory is not a function or class
INJECUTE_INVALID_DEPENDENCYA dependency is not a key, optional(key), collect(tag) or a function
INJECUTE_CLASS_NOT_CONSTRUCTEDA class was called without new
INJECUTE_RESOLUTION_FAILEDA factory threw (or its promise rejected) while creating a service
INJECUTE_NOT_A_FUNCTIONcall() was used on a service that is not a function
INJECUTE_NAMESPACE_CONFLICTThe namespace name is already used by a service
INJECUTE_NAMESPACE_RESULTA namespace callback returned something other than a new container
INJECUTE_EXTENSION_RESULTAn extension returned a container that is not this one or its child
INJECUTE_SEALEDThe container is sealed
INJECUTE_DISPOSEDThe container is disposed
INJECUTE_DISPOSE_FAILEDSome services failed to dispose
INJECUTE_WIRING_FAILEDThe wiring check found services that are missing or fail
INJECUTE_INVALID_OPTIONAn option is not supported here
INJECUTE_UNKNOWN_EVENTUnknown event name
INJECUTE_READ_ONLYThe object is read-only
INJECUTE_INVALID_HOOKA lifecycle hook is not registered correctly
INJECUTE_UNDO_FAILEDA lifecycle hook could not be undone
INJECUTE_LIFECYCLE_STOPPEDThe lifecycle of this container was stopped

Hints in browser bundles ​

Bundlers that build for browsers leave the hints out of error messages, to keep the bundle small (about 1.5 kB gzipped). Messages keep what happened and the docs link; error.code and error.docs are the same everywhere.

Where it runsHints in messages
Node.js, Deno, Bun, server-side rendering, browsers without a bundleralways
Vite and webpack, development (the dev server, --mode development)yes
Vite and webpack, production buildsno
esbuild, Rolldownno, unless you add the development condition (conditions: ['development'])

To have them in any build, import injecute/hints where you want them:

ts
// in development only, with any bundler
if (import.meta.env.DEV) await import('injecute/hints');

// or in every build (staging, or debugging a production build)
import 'injecute/hints';

Without a bundler, and on servers, the import does nothing: those messages have the hints already. An error thrown before a dynamic import() finishes has no hint; a static import doesn't have that gap.

Released under the MIT License.