---
url: https://masyaka.github.io/injecute/errors/resolution-failed.md
description: A factory threw (or its promise rejected) while creating a service
---

# `INJECUTE_RESOLUTION_FAILED`

**A factory threw (or its promise rejected) while creating a service.**

## How to fix it

The original error is in `cause`; `path` shows which service needed it.

## Reading it

The message starts with `Failed to create "<key>": <original message>`, and the `Resolving:` line shows
the chain of services that led to it. The original error is `error.cause`:

```ts
try {
  app.get('users');
} catch (error) {
  if (
    error instanceof InjecuteError &&
    error.code === 'INJECUTE_RESOLUTION_FAILED'
  ) {
    console.error(error.path, error.cause);
  }
}
```

Errors that are already `InjecuteError`s (for example a missing dependency deeper in the graph) are not
wrapped again.

## Handling it in code

```ts
import { InjecuteError } from 'injecute';

try {
  // ...
} catch (error) {
  if (error instanceof InjecuteError && error.code === 'INJECUTE_RESOLUTION_FAILED') {
    // error.message explains what happened; error.path is the resolution chain
  }
}
```

[All error codes](./index.md)
