4 ms·
Including the filename is a highly opinionated decision. First of all it means your error value needs to have a string in it at minimum, which means extra overh
by cdogl 3y ago
Including the filename is a highly opinionated decision. First of all it means your error value needs to have a string in it at minimum, which means extra overhead compared (eg) an enum that could compile down to an int. Maybe you don’t normally care, but the standard library has to. The caller always has the context needed to know what file wasn’t found and propagate it as appropriate. This also introduces a whole angle around ownership of that memory in a language like Rust, and would be a huge headache in C.
It also increases the surface area of the API which makes everything around it less portable and may mean it’s awkward to mock in tests.