JSONError
public enum JSONError: Error
A type representing JSON parsing and deserialization errors.
-
The JSON appears to be invalid.
underlyingError: the error thrown byJSONSerialization.jsonObject(with:options:).
Declaration
Swift
case invalidJSON(underlyingError: NSError)
-
The
Stringcould not be encoded in UTF-8.string: the string that caused the error.
Declaration
Swift
case invalidUTF8String(string: String)
-
The deserializer encountered an unexpected value.
cause: the reason the value is invalid.
Declaration
Swift
case invalidValue(cause: String)
-
A value required by the deserializer was missing.
name: the name of the missing value.
Declaration
Swift
case missingValue(name: String)
-
The deserializer encountered an unexpected type.
type: the type found.whenDeserializing: the type we were deserializing.
Declaration
Swift
case unexpectedType(type: String, whenDeserializing: String)
-
Convert this
JSONErrorinto anNSError.Note
TheNSError’slocalizedDescriptionwill always be a human readable english.Note
For
invalidJSON, theuserInfoalso has a value forNSUnderlyingErrorKey.Declaration
Swift
public func toNSError() -> NSErrorReturn Value
An
NSErrorcorresponding toself.
View on GitHub
Install in Dash
JSONError Enum Reference