Skip to content

Commit 306b0d6

Browse files
author
Michael Long
committed
Add debug message to resolve in case of Optionals and ImplicitlyUnrwappedOptionals.
1 parent 8bb2560 commit 306b0d6

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Resolver Changelog
22

3+
### 1.0.2
4+
5+
* Add debug message to resolve in case of Optionals and ImplicitlyUnrwappedOptionals.
6+
37
### 1.0.1
48

59
* Make ResolverScopeCache initializer visible

Resolver.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "Resolver"
3-
s.version = "1.0.1"
3+
s.version = "1.0.2"
44
s.summary = "An ultralight Dependency Injection / Service Locator framework for Swift 4 and iOS."
55
s.homepage = "https://github.com/hmlongco/Resolver"
66
s.license = "MIT"

Sources/Resolver.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,17 @@ public final class Resolver {
172172
let service = registration.scope.resolve(resolver: self, registration: registration, args: args) {
173173
return service
174174
}
175-
fatalError("RESOLVER: '\(Service.self):\(name ?? "")' not resolved")
175+
#if DEBUG
176+
let typeName = String(describing: type)
177+
if typeName.contains("Optional<") {
178+
let message = "RESOLVER: \(typeName) not resolved. To disambiguate use resover.optional() instead of resover.resolve()."
179+
print(message)
180+
fatalError(message)
181+
}
182+
#endif
183+
let message = "RESOLVER: '\(Service.self):\(name ?? "")' not resolved."
184+
print(message)
185+
fatalError(message)
176186
}
177187

178188
/// Static function calls the root registry to resolve an optional Service type.

0 commit comments

Comments
 (0)