Skip to content

Add requester type info to DI missing-instance exception#28

Open
Red-Cat-Fat wants to merge 1 commit intodevelopfrom
codex/add-class-name-to-notfoundinstanceorcreateexception
Open

Add requester type info to DI missing-instance exception#28
Red-Cat-Fat wants to merge 1 commit intodevelopfrom
codex/add-class-name-to-notfoundinstanceorcreateexception

Conversation

@Red-Cat-Fat
Copy link
Owner

Motivation

  • Improve diagnostics when the DI system fails to resolve a dependency by including the type that requested the missing instance in the thrown exception message.

Description

  • Extended NotFoundInstanceOrCreateException to store RequesterType and include it in the formatted message when available.
  • Propagated requester metadata from the Injector into the resolve context using RequesterTypeContextKey so the container knows which type initiated the parameter resolution.
  • Updated ApplicationContainer.GetSingle to extract the requester type from the context and pass it into the NotFoundInstanceOrCreateException when throwing.
  • Added a unit test GivenApplicationContainer_WhenInjectNotContainInstance_ThenCatchRequesterTypeInException to validate RequesterType is populated on injection failure.

Testing

  • Ran git diff --check to validate workspace changes with no whitespace/patch issues and it passed.
  • Updated NUnit test coverage in ExceptionDiContainerTests.cs, but the Unity/NUnit test runner was not executed in this environment so tests were not run here.
  • No automated runtime/unit tests were executed due to lack of a Unity test runner in this environment.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant