Skip to content

Improve error message for "No provider for" errors. #46189

@Burgov

Description

@Burgov

Which @angular/* package(s) are relevant/related to the feature request?

core

Description

In complex applications, it can be very tedious to debug "No provider for" errors, because Angular doesn't tell me what component or service it's trying to resolve when running into this error.

In my particular case, I have several components which have optional dependencies, depending on where in the application it is loaded. These dependencies are typically defined on parent components (or not). Clearly I forgot to mark it optional somewhere in one of my components, but in order to find out which one, I have to put a breakpoint on the error, go up several levels and hope to find what component it is instantiating.

Proposed solution

It would be very helpful if the error changed from "No provider for {requestedService}" to "No provider for {requestedService} while instantiating {component, service, pipe or whatever}"

Alternatives considered

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreIssues related to the framework runtimecore: difeatureLabel used to distinguish feature request from other issuesfeature: under considerationFeature request for which voting has completed and the request is now under considerationhotlist: error messages

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions