-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Print nested types in errors, hash keys using full typenames #221
Conversation
} | ||
|
||
func reflect(_ type: Any.Type) -> String | ||
{ | ||
return String(reflecting: type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please just use this rather than introducing free function?
@@ -41,7 +41,7 @@ public struct DefinitionKey: Hashable, CustomStringConvertible { | |||
} | |||
|
|||
public var description: String { | |||
return "type: \(type), arguments: \(typeOfArguments), tag: \(tag.desc)" | |||
return "type: \(reflect(type)), arguments: \(typeOfArguments), tag: \(tag.desc)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return "type: \(reflect(type)), arguments: \(typeOfArguments), tag: \(tag.desc)" | |
return "type: \(String(reflecting: type)), arguments: \(typeOfArguments), tag: \(tag.desc)" |
@@ -77,18 +77,21 @@ public enum DipError: Error, CustomStringConvertible { | |||
public var description: String { | |||
switch self { | |||
case let .definitionNotFound(key): | |||
return "No definition registered for \(key).\nCheck the tag, type you try to resolve, number, order and types of runtime arguments passed to `resolve()` and match them with registered factories for type \(key.type)." | |||
return "No definition registered for \(key).\nCheck the tag, type you try to resolve, number, order and types of runtime arguments passed to `resolve()` and match them with registered factories for type \(reflect(key.type))." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return "No definition registered for \(key).\nCheck the tag, type you try to resolve, number, order and types of runtime arguments passed to `resolve()` and match them with registered factories for type \(reflect(key.type))." | |
return "No definition registered for \(key).\nCheck the tag, type you try to resolve, number, order and types of runtime arguments passed to `resolve()` and match them with registered factories for type \(String(reflecting: key.type))." |
case let .autoInjectionFailed(label, type, error): | ||
return "Failed to auto-inject property \"\(label.desc)\" of type \(type). \(error)" | ||
return "Failed to auto-inject property \"\(label.desc)\" of type \(reflect(type)). \(error)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return "Failed to auto-inject property \"\(label.desc)\" of type \(reflect(type)). \(error)" | |
return "Failed to auto-inject property \"\(label.desc)\" of type \(String(reflecting: type)). \(error)" |
case let .autoWiringFailed(type, error): | ||
return "Failed to auto-wire type \"\(type)\". \(error)" | ||
return "Failed to auto-wire type \"\(reflect(type))\". \(error)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return "Failed to auto-wire type \"\(reflect(type))\". \(error)" | |
return "Failed to auto-wire type \"\(String(reflecting: type))\". \(error)" |
case let .ambiguousDefinitions(type, definitions): | ||
return "Ambiguous definitions for \(type):\n" + | ||
return "Ambiguous definitions for \(reflect(type)):\n" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return "Ambiguous definitions for \(reflect(type)):\n" + | |
return "Ambiguous definitions for \(String(reflecting: type)):\n" + |
definitions.map({ "\($0)" }).joined(separator: ";\n") | ||
case let .invalidType(resolved, key): | ||
return "Resolved instance \(resolved ?? "nil") does not implement expected type \(key.type)." | ||
return "Resolved instance \(resolved ?? "nil") does not implement expected type \(reflect(key.type))." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return "Resolved instance \(resolved ?? "nil") does not implement expected type \(reflect(key.type))." | |
return "Resolved instance \(resolved ?? "nil") does not implement expected type \(String(reflecting: key.type))." |
Hi Ilya, we're using nested types a lot and the "leafs" have identical names, which leads to conflicts when type matching and non-specific log messages. This change uses the fully scoped names.