Java and C# famously solve this with a hidden implicit return value for errors: the exception. The current trend in language design is to take the same idea and make it explicit instead, using sum types. Like Rust's `Result`, where the result contains either the normal value or an error, but never both
Of course C++ gives you the option to do any of the above, and still contains insane API contracts
Of course C++ gives you the option to do any of the above, and still contains insane API contracts