typedi icon indicating copy to clipboard operation
typedi copied to clipboard

Better error messages

Open freshgum-bubbles opened this issue 1 year ago • 0 comments

I'd like the next few releases to focus on the backlog, and on refining the Container. Specifically, error messages.

In cases such as this, it would be nice to state some possible reasons why this would happen, and how to fix it.

There are plenty of other examples too. I'll compile a list.

1. Resolution Errors

After making a few changes in my app, I've stumbled across... this:

/home/freshgum/app/node_modules/.pnpm/@[email protected]/node_modules/@freshgum/typedi/build/esm5/container-instance.class.mjs:173
            throw new ServiceNotFoundError(identifier);
                  ^


ServiceNotFoundError: Service with "Token<DB filename>" identifier was not found in the container. Register it before usage via "Container.set" or the "@Service()" decorator.
    at ContainerInstance.get (/home/freshgum/app/node_modules/.pnpm/@[email protected]/node_modules/@freshgum/typedi/build/esm5/container-instance.class.mjs:173:19)
    at ContainerInstance.resolveResolvable (/home/freshgum/app/node_modules/.pnpm/@[email protected]/node_modules/@freshgum/typedi/build/esm5/container-instance.class.mjs:1123:21)
    at <anonymous> (/home/freshgum/app/node_modules/.pnpm/@[email protected]/node_modules/@freshgum/typedi/build/esm5/container-instance.class.mjs:1062:52)
    at Array.map (<anonymous>)
    at ContainerInstance.getConstructorParameters (/home/freshgum/app/node_modules/.pnpm/@[email protected]/node_modules/@freshgum/typedi/build/esm5/container-instance.class.mjs:1062:29)
    at ContainerInstance.getServiceValue (/home/freshgum/app/node_modules/.pnpm/@[email protected]/node_modules/@freshgum/typedi/build/esm5/container-instance.class.mjs:1042:37)
    at ContainerInstance.getOrDefault (/home/freshgum/app/node_modules/.pnpm/@[email protected]/node_modules/@freshgum/typedi/build/esm5/container-instance.class.mjs:373:25)
    at ContainerInstance.getOrDefault (/home/freshgum/app/node_modules/.pnpm/@[email protected]/node_modules/@freshgum/typedi/build/esm5/container-instance.class.mjs:339:40)
    at ContainerInstance.get (/home/freshgum/app/node_modules/.pnpm/@[email protected]/node_modules/@freshgum/typedi/build/esm5/container-instance.class.mjs:171:31)
    at ContainerInstance.resolveResolvable (/home/freshgum/app/node_modules/.pnpm/@[email protected]/node_modules/@freshgum/typedi/build/esm5/container-instance.class.mjs:1123:21) {
  normalizedIdentifier: 'Token<DB filename>'
}

This is shit. How has the error originated? A stack trace of resolutions would be helpful here, e.g.

Token<DB filename>
WikiDatabaseService
AnotherService
YetAnotherService
WoahAnotherService
Container(default)

freshgum-bubbles avatar May 13 '24 02:05 freshgum-bubbles