Instance Method

failWithError(_:)

Signals to this coder that the decode operation has failed.

Declaration

func failWithError(_ error: Error)

Parameters

error

An error that indicates why decoding failed.

Discussion

Typically, you call this method in your init(coder:) implementation. You should set the error when you detect problems such as lack of secure coding, data corruption, or a domain validation failure.

This method is only meaningful to call for decodes.

The effect of calling this method depends on the value of decodingFailurePolicy, as follows:

See Also

Managing Decode Errors

var error: Error?

An error in the top-level encode.