0001    //
0002    //  DecodingError.swift
0003    //  Decodable
0004    //
0005    //  Created by Johannes Lund on 2015-07-17.
0006    //  Copyright © 2015 anviking. All rights reserved.
0007    //
0008    
0009    import Foundation
0010    
0011    /// Errors conforming DecodingError will be caught and rethrown in the decoding process with updated metadata.
0012    public protocol DecodingError
DecodingError.swift:26
extension DecodingError {
DecodingError.swift:33
public struct TypeMismatchError: DecodingError {
DecodingError.swift:53
public struct MissingKeyError: DecodingError {
DecodingError.swift:72
public struct RawRepresentableInitializationError: DecodingError {
Parse.swift:55
    } catch let error as DecodingError {
: ErrorType { 0013 /// The JSON key path to the object that failed to be decoded 0014 var path
DecodingError.swift:29
        return path.joinWithSeparator(".")
Parse.swift:57
        error.path = path + error.path
Parse.swift:57
        error.path = path + error.path
: [String] {get set} 0015 0016 /// The JSON object that failed to be decoded 0017 var object: AnyObject {get} 0018 0019 /// The root JSON object for which the `path` can be used to find `object` 0020 var rootObject
Parse.swift:58
        error.rootObject = json
: AnyObject? {get set} 0021 0022 0023 var formattedPath: String {get} 0024 } 0025 0026 extension DecodingError { 0027 /// Represents the path to the object that failed decoding with "." as a separator. 0028 public var formattedPath
DecodingError.swift:50
        return "TypeMismatchError expected: \(expectedType) but \(object) is of type \(receivedType) in \(formattedPath)"    }
DecodingError.swift:68
        return "Missing Key \(key) in \(formattedPath) \(object)"
: String { 0029 return path.joinWithSeparator(".") 0030 } 0031 } 0032 0033 public struct TypeMismatchError
Castable.swift:16
            throw TypeMismatchError(expectedType: self, receivedType: j.dynamicType, object: j)
Decodable.swift:18
            throw TypeMismatchError(expectedType: self, receivedType: j.dynamicType, object: j)
Decodable.swift:27
            throw TypeMismatchError(expectedType: self, receivedType: j.dynamicType, object: j)
NSValueCastable.swift:27
            throw TypeMismatchError(expectedType: NSValue.self, receivedType: j.dynamicType, object: j)
: DecodingError { 0034 0035 public init
Castable.swift:16
            throw TypeMismatchError(expectedType: self, receivedType: j.dynamicType, object: j)
Decodable.swift:18
            throw TypeMismatchError(expectedType: self, receivedType: j.dynamicType, object: j)
Decodable.swift:27
            throw TypeMismatchError(expectedType: self, receivedType: j.dynamicType, object: j)
NSValueCastable.swift:27
            throw TypeMismatchError(expectedType: NSValue.self, receivedType: j.dynamicType, object: j)
(expectedType: Any.Type, receivedType: Any.Type, object: AnyObject) { 0036 self.expectedType = expectedType 0037 self.receivedType = receivedType 0038 self.object = object 0039 self.path = [] 0040 } 0041 0042 public let expectedType
DecodingError.swift:36
        self.expectedType = expectedType
DecodingError.swift:50
        return "TypeMismatchError expected: \(expectedType) but \(object) is of type \(receivedType) in \(formattedPath)"    }
: Any.Type 0043 public let receivedType
DecodingError.swift:37
        self.receivedType = receivedType
DecodingError.swift:50
        return "TypeMismatchError expected: \(expectedType) but \(object) is of type \(receivedType) in \(formattedPath)"    }
: Any.Type 0044 0045 public var path
DecodingError.swift:39
        self.path = []
: [String] 0046 public let object
DecodingError.swift:38
        self.object = object
DecodingError.swift:50
        return "TypeMismatchError expected: \(expectedType) but \(object) is of type \(receivedType) in \(formattedPath)"    }
: AnyObject 0047 public var rootObject: AnyObject? 0048 0049 public var debugDescription: String { 0050 return "TypeMismatchError expected: \(expectedType) but \(object) is of type \(receivedType) in \(formattedPath)" } 0051 } 0052 0053 public struct MissingKeyError
Parse.swift:16
            var error = MissingKeyError(key: key, object: currentDict)
Parse.swift:47
    } catch is MissingKeyError {
: DecodingError { 0054 0055 public let key
DecodingError.swift:62
        self.key = key
DecodingError.swift:68
        return "Missing Key \(key) in \(formattedPath) \(object)"
: String 0056 0057 public var path
DecodingError.swift:64
        self.path = []
Parse.swift:17
            error.path = a.currentPath
: [String] 0058 public let object
DecodingError.swift:63
        self.object = object
DecodingError.swift:68
        return "Missing Key \(key) in \(formattedPath) \(object)"
: AnyObject 0059 public var rootObject
Parse.swift:18
            error.rootObject = json
: AnyObject? 0060 0061 public init
Parse.swift:16
            var error = MissingKeyError(key: key, object: currentDict)
(key: String, object: AnyObject) { 0062 self.key = key 0063 self.object = object 0064 self.path = [] 0065 } 0066 0067 public var debugDescription: String { 0068 return "Missing Key \(key) in \(formattedPath) \(object)" 0069 } 0070 } 0071 0072 public struct RawRepresentableInitializationError
RawRepresentableDecodable.swift:20
            throw RawRepresentableInitializationError(type: self, rawValue: rawValue, object: json)
: DecodingError { 0073 public let type
DecodingError.swift:82
        self.type = type
DecodingError.swift:88
        return "RawRepresentableInitializationError: \(rawValue) could not be used to initialize \(type). (path: \(path))"
: Any.Type 0074 public let rawValue
DecodingError.swift:81
        self.rawValue = rawValue
DecodingError.swift:88
        return "RawRepresentableInitializationError: \(rawValue) could not be used to initialize \(type). (path: \(path))"
: Any 0075 0076 public var path
DecodingError.swift:84
        self.path = []
DecodingError.swift:88
        return "RawRepresentableInitializationError: \(rawValue) could not be used to initialize \(type). (path: \(path))"
: [String] 0077 public let object
DecodingError.swift:83
        self.object = object
: AnyObject 0078 public var rootObject: AnyObject? 0079 0080 public init
RawRepresentableDecodable.swift:20
            throw RawRepresentableInitializationError(type: self, rawValue: rawValue, object: json)
(type: Any.Type, rawValue: Any, object: AnyObject) { 0081 self.rawValue = rawValue 0082 self.type = type 0083 self.object = object 0084 self.path = [] 0085 } 0086 0087 public var debugDescription: String { 0088 return "RawRepresentableInitializationError: \(rawValue) could not be used to initialize \(type). (path: \(path))" 0089 } 0090 } 0091 0092 // Allow types to be used in pattern matching 0093 // E.g case TypeMismatchError(NSNull.self, _, _) but be careful 0094 // You probably rather want to modify the decode-closure 0095 // There are overloads for this 0096 public func ~=<T>(lhs: T.Type, rhs: Any.Type) -> Bool { 0097 return lhs == rhs 0098 } 0099 0100