Improve error context for DI

This commit is contained in:
2022-08-10 21:53:56 -05:00
parent 9b47d2ac99
commit 3d836afa59
4 changed files with 60 additions and 20 deletions

View File

@@ -1,11 +1,12 @@
import {DependencyKey} from '../types'
import {ErrorWithContext} from '../../util'
/**
* Error thrown when a dependency key that has not been registered is passed to a resolver.
* @extends Error
*/
export class InvalidDependencyKeyError extends Error {
constructor(key: DependencyKey) {
super(`No such dependency is registered with this container: ${key}`)
export class InvalidDependencyKeyError extends ErrorWithContext {
constructor(key: DependencyKey, context: {[key: string]: any} = {}) {
super(`No such dependency is registered with this container: ${key}`, context)
}
}