I maintain a library where a user can publish a message and I want to accept any iodata (I end up writing it to a TCP connection), but I would to return an error as soon as possible if someone passes an argument that is not valid iodata.
Rather than sending that data to a GenServer and dealing with a badarg
error, I would like to guard against the bad argument at the edge of my API and return a descriptive error message.
Is there a way to pattern match against iodata? Or check it in a guard clause? Or even check it in the function body?