Skip to content
This repository was archived by the owner on Jun 18, 2019. It is now read-only.

Commit 58bbccf

Browse files
author
Kevin Lundberg
committed
Preserve key info in dictionaries that are attempted to be unboxed as well
1 parent b0f1d15 commit 58bbccf

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Sources/Dictionary+Unbox.swift

+10-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,16 @@ extension Dictionary: UnboxableCollection {
2222
throw UnboxPathError.invalidDictionaryKey(key)
2323
}
2424

25-
guard let unboxedValue = try transformer.unbox(element: value, allowInvalidCollectionElements: allowInvalidElements) else {
25+
let transformedValue: Value?
26+
do {
27+
transformedValue = try transformer.unbox(element: value, allowInvalidCollectionElements: allowInvalidElements)
28+
} catch let error as UnboxPathError {
29+
throw UnboxError.pathError(error, "\(key)")
30+
} catch UnboxError.pathError(let pathError, let path) {
31+
throw UnboxError.pathError(pathError, "\(key).\(path)")
32+
}
33+
34+
guard let unboxedValue = transformedValue else {
2635
throw UnboxPathError.invalidDictionaryValue(value, key, T.UnboxedElement.self)
2736
}
2837

0 commit comments

Comments
 (0)