@@ -2026,13 +2026,18 @@ public enum EncodingError : Error {
2026
2026
/// A description of what went wrong, for debugging purposes.
2027
2027
public let debugDescription : String
2028
2028
2029
+ /// The underlying error which caused this error, if any.
2030
+ public let underlyingError : Error ?
2031
+
2029
2032
/// Initializes `self` with the given path of `CodingKey`s and a description of what went wrong.
2030
2033
///
2031
2034
/// - parameter codingPath: The path of `CodingKey`s taken to get to the point of the failing encode call.
2032
2035
/// - parameter debugDescription: A description of what went wrong, for debugging purposes.
2033
- public init ( codingPath: [ CodingKey ? ] , debugDescription: String ) {
2036
+ /// - parameter underlyingError: The underlying error which caused this error, if any.
2037
+ public init ( codingPath: [ CodingKey ? ] , debugDescription: String , underlyingError: Error ? = nil ) {
2034
2038
self . codingPath = codingPath
2035
2039
self . debugDescription = debugDescription
2040
+ self . underlyingError = underlyingError
2036
2041
}
2037
2042
}
2038
2043
@@ -2052,13 +2057,18 @@ public enum DecodingError : Error {
2052
2057
/// A description of what went wrong, for debugging purposes.
2053
2058
public let debugDescription : String
2054
2059
2060
+ /// The underlying error which caused this error, if any.
2061
+ public let underlyingError : Error ?
2062
+
2055
2063
/// Initializes `self` with the given path of `CodingKey`s and a description of what went wrong.
2056
2064
///
2057
2065
/// - parameter codingPath: The path of `CodingKey`s taken to get to the point of the failing decode call.
2058
2066
/// - parameter debugDescription: A description of what went wrong, for debugging purposes.
2059
- public init ( codingPath: [ CodingKey ? ] , debugDescription: String ) {
2067
+ /// - parameter underlyingError: The underlying error which caused this error, if any.
2068
+ public init ( codingPath: [ CodingKey ? ] , debugDescription: String , underlyingError: Error ? = nil ) {
2060
2069
self . codingPath = codingPath
2061
2070
self . debugDescription = debugDescription
2071
+ self . underlyingError = underlyingError
2062
2072
}
2063
2073
}
2064
2074
0 commit comments