On Monday, 26 June 2017 at 18:42:24 UTC, Ola Fosheim Grøstad wrote:
On Monday, 26 June 2017 at 17:44:15 UTC, Guillaume Boucher wrote:
Java uses A, Rust/Go use B. C++ uses B to some extend (e.g. in std::experimental::filesystem).

The C++17 filesystem api provides two alternatives, the standard filesystem_error exception and an output-paramater for capturing os-specific error codes. I'm not quite sure why they provide both, but I guess performance and the ability to compile for runtimes with exceptions turned off could explain it.

Quoting the C++ standard:

Filesystem library functions often provide two overloads, one that throws an exception to report file system errors, and another that sets an error_code.

[Note: This supports two common use cases:

   - Uses where file system errors are truly exceptional
     and indicate a serious failure.
     Throwing an exception is an appropriate response.
   - Uses where file system errors are routine
     and do not necessarily represent failure.
     Returning an error code is the most appropriate response.
This allows application specific error handling, including simply ignoring the error.

 -- end note]

I would say that the overload without exceptions is the "standard" one.

It is rather clear though that C++ std lib relies heavily on exceptions.

[Citation needed]

Reply via email to