 
   # constructors for errors which are catchable with bluebirds `catch`
 
-  hinoki.errors = {}
-
-  hinoki.errors.ErrorInResolvers = (path, containers, error) ->
+  # the base error for all other hinoki errors
+  # not to be instantiated directly
+  hinoki.BaseError = ->
+  hinoki.BaseError.prototype = new Error
+  hinoki.BaseError.prototype.name = 'BaseError'
+
+  hinoki.ErrorInResolversError = (path, containers, error) ->
     this.message = "error in resolvers for '#{path[0]}' (#{hinoki.pathToString path}). original error: #{error.toString()}"
-    this.type = 'ErrorInResolver'
     this.path = path
     this.containers = containers
     this.error = error
     if Error.captureStackTrace
       Error.captureStackTrace(this, this.constructor)
-  hinoki.errors.ErrorInResolvers.prototype = new Error
-
-  hinoki.errors.Unresolvable = (path, container) ->
+  hinoki.ErrorInResolversError.prototype = new hinoki.BaseError
+  hinoki.ErrorInResolversError.prototype.name = 'ErrorInResolversError'
+
+  hinoki.UnresolvableError = (path, container) ->
     this.message = "unresolvable name '#{path[0]}' (#{hinoki.pathToString path})"
-    this.type = 'Unresolvable'
     this.path = path
     this.container = container
     if Error.captureStackTrace
       Error.captureStackTrace(this, this.constructor)
-  hinoki.errors.Unresolvable.prototype = new Error
-
-  hinoki.errors.InvalidResolution = (path, resolution, errors) ->
+  hinoki.UnresolvableError.prototype = new hinoki.BaseError
+  hinoki.UnresolvableError.prototype.name = 'UnresolvableError'
+
+  hinoki.InvalidResolutionError = (path, resolution, errors) ->
     lines = errors
     lines.unshift "errors in resolution returned by resolvers for '#{path[0]}' (#{hinoki.pathToString path}):"
     this.message = lines.join '\n'
-    this.type = 'InvalidResolution'
     this.path = path
     this.resolution = resolution
     if Error.captureStackTrace
       Error.captureStackTrace(this, this.constructor)
-  hinoki.errors.InvalidResolution.prototype = new Error
-
-  hinoki.errors.CircularDependency = (path, containers) ->
+  hinoki.InvalidResolutionError.prototype = new hinoki.BaseError
+  hinoki.InvalidResolutionError.prototype.name = 'InvalidResolutionError'
+
+  hinoki.CircularDependencyError = (path, containers) ->
     this.message = "circular dependency #{hinoki.pathToString path}"
-    this.type = 'CircularDependency'
     this.path = path
     this.containers = containers
     if Error.captureStackTrace
       Error.captureStackTrace(this, this.constructor)
-  hinoki.errors.CircularDependency.prototype = new Error
-
-  hinoki.errors.ErrorInFactory = (path, container, error) ->
+  hinoki.CircularDependencyError.prototype = new hinoki.BaseError
+  hinoki.CircularDependencyError.prototype.name = 'CircularDependencyError'
+
+  hinoki.ThrowInFactoryError = (path, container, error) ->
     this.message = "error in factory for '#{path[0]}'. original error: #{error.toString()}"
-    this.type = 'ErrorInFactory'
     this.path = path
     this.container = container
     this.error = error
     if Error.captureStackTrace
       Error.captureStackTrace(this, this.constructor)
-  hinoki.errors.ErrorInFactory.prototype = new Error
-
-  hinoki.errors.FactoryReturnedUndefined = (path, container, factory) ->
+  hinoki.ThrowInFactoryError.prototype = new hinoki.BaseError
+  hinoki.ThrowInFactoryError.prototype.name = 'ThrowInFactoryError'
+
+  hinoki.FactoryReturnedUndefinedError = (path, container, factory) ->
     this.message = "factory for '#{path[0]}' returned undefined"
-    this.type = 'FactoryReturnedUndefined'
     this.path = path
     this.container = container
     this.factory = factory
     if Error.captureStackTrace
       Error.captureStackTrace(this, this.constructor)
-  hinoki.errors.FactoryReturnedUndefined.prototype = new Error
-
-  hinoki.errors.PromiseRejected = (path, container, error) ->
+  hinoki.FactoryReturnedUndefinedError.prototype = new hinoki.BaseError
+  hinoki.FactoryReturnedUndefinedError.prototype.name = 'FactoryReturnedUndefinedError'
+
+  hinoki.PromiseRejectedError = (path, container, error) ->
     this.message = "promise returned from factory for '#{path[0]}' was rejected. original error: #{error.toString()}"
-    this.type = 'PromiseRejected'
     this.path = path
     this.container = container
     this.error = error
     if Error.captureStackTrace
       Error.captureStackTrace(this, this.constructor)
-  hinoki.errors.PromiseRejected.prototype = new Error
+  hinoki.PromiseRejectedError.prototype = new hinoki.BaseError
+  hinoki.PromiseRejectedError.prototype.name = 'PromiseRejectedError'
 
   ###################################################################################
   # path

      .then (value) ->
        # note that a null value is allowed!
        if hinoki.isUndefined value
          return Promise.reject new hinoki.errors.FactoryReturnedUndefined newPath, resolution.container, resolution.factory

        # cache
        unless nocache

    try
      valueOrPromise = factory.apply null, dependencyValues
    catch error
      return Promise.reject new hinoki.ThrowInFactoryError path, container, error

    unless hinoki.isThenable valueOrPromise
      # valueOrPromise is not a promise but an value
