I have a (common) situation where I am currently returning a result that is a mixed type, sometimes a boolean, sometimes an error message. For example:
function checked_thing_is_legal(){
// Do stuff and check for errors in here.
} // Returns true if there are no errors, otherwise returns an error message string.
This feels dirty, and someone once said "it's good to distill code down to single, reliable return values", which I find to be good advice. So what is a better paradigm to check for errors?