DecodingError

enum DecodingError

An error that occurs during the decoding of a value.

Inheritance Error
Nested Types DecodingError.Context

Cases

case dataCorrupted Required

An indication that the data is corrupted or otherwise invalid.

As an associated value, this case contains the context for debugging.

Declaration

case dataCorrupted(: DecodingError.Context)
case keyNotFound Required

An indication that a keyed decoding container was asked for an entry for the given key, but did not contain one.

As associated values, this case contains the attempted key and context for debugging.

Declaration

case keyNotFound(: CodingKey, : DecodingError.Context)
case typeMismatch Required

An indication that a value of the given type could not be decoded because it did not match the type of what was found in the encoded payload.

As associated values, this case contains the attempted type and context for debugging.

Declaration

case typeMismatch(: Any.Type, : DecodingError.Context)
case valueNotFound Required

An indication that a non-optional value of the given type was expected, but a null value was found.

As associated values, this case contains the attempted type and context for debugging.

Declaration

case valueNotFound(: Any.Type, : DecodingError.Context)

Type Methods

func dataCorruptedError(forKey key: C.Key, in container: C, debugDescription: String) -> DecodingError Required

Returns a new .dataCorrupted error using a constructed coding path and the given debug description.

The coding path for the returned error is constructed by appending the given key to the given container's coding path.

  • param key: The key which caused the failure.
  • param container: The container in which the corrupted data was accessed.
  • param debugDescription: A description of the error to aid in debugging.

Declaration

public static func dataCorruptedError<C>(forKey key: C.Key, in container: C, debugDescription: String) -> DecodingError where C: KeyedDecodingContainerProtocol
func dataCorruptedError(in container: UnkeyedDecodingContainer, debugDescription: String) -> DecodingError Required

Returns a new .dataCorrupted error using a constructed coding path and the given debug description.

The coding path for the returned error is constructed by appending the given container's current index to its coding path.

  • param container: The container in which the corrupted data was accessed.
  • param debugDescription: A description of the error to aid in debugging.

Declaration

public static func dataCorruptedError(in container: UnkeyedDecodingContainer, debugDescription: String) -> DecodingError
func dataCorruptedError(in container: SingleValueDecodingContainer, debugDescription: String) -> DecodingError Required

Returns a new .dataCorrupted error using a constructed coding path and the given debug description.

The coding path for the returned error is the given container's coding path.

  • param container: The container in which the corrupted data was accessed.
  • param debugDescription: A description of the error to aid in debugging.

Declaration

public static func dataCorruptedError(in container: SingleValueDecodingContainer, debugDescription: String) -> DecodingError