Errors from custom Encodable implementations.
This is an implementation detal; and JSONEncoder can store this path without protocol requirement. What the use of it inside custom Encodable implementation? (Since we already have EncodingError.Context.codingPath)
But again, this is about Foundation
and its hidden implementation, not about Codable
itself. My Coders are public and I found useful to call .encode(to: )
or type.init(from: )
directly.
That was what I meant, it is of course an implementation detail of encoder how you get it. I suppose it is meant to facilitate the same as property on encoder, so that an encoding instance can see where it is in the encoding hierarchy. I guess @itaiferber knows the real reason.
This might apply for your usage, but just not for any encoder. This kind of thing is required for those purposes in more closed environments and especially if you wan't to use multiple encoders from multiple sources/it's just a unified way to do it.