News for hackers. Stuff that matters.
Re:Parse, Don't Validate (2019) by jameshart on Tuesday March 07, 2023 @08:53AM (#35055315)
When you’re building a ‘parser’ (in this broad, type-narrowing sense) to handle user-supplied data, the result type really needs to be a rich mix of

- successfully parsed data objects

- error objects

- warning objects

That way your consumers can themselves decide what to do in the face of errors and warnings.

(Of course one ugly old fashioned way to add optional ‘error’ types to your return signature is checked exceptions, but we don’t talk about that model any more.)

There are no comments on this comment yet.