Go does it well. You can return two values: the actual result and the error code.
Python is also cool in this regard. e,g, QUADPACK routines.
I do the same in std::tuple but in Python it's automagic .. it just knows it's a tuple.
Caveat: if you call these functions in a for loop that return tuples it's very bad for performance, so avoid tuple creation/destruction. Example,MC for RNG (Box-Muller returns a tuple) difference of 60 seconds versus 3600 seconds for NT = 500, NSIM = 1'000'000. Was a surprise the first time.