Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What stability issues?




Unchecked exceptions will eventually lead into programs crashing because some developer forgot to catch specific type of exception somewhere.

And developers never forget to check error codes.

Looking at code, it‘s easier to spot the missing check for an error code, than a not catched exceptions.

Also error codes are part of the signature of a function, which exceptions aren‘t.


If you need to wrap each call in try/catch, it's better to use return codes in some form or rethink the approach.

may I introduce you to the nodiscard attribute[1]?

  enum (class)? [[nodiscard]] Error {
    Ok,
    NoMem,
    ...
  };
[1]: https://en.cppreference.com/w/cpp/language/attributes/nodisc...


FWIW I’ve been using warn_unused_result in both gcc and clang since about 2020.

Yep, partial remedies are available for quite some time.

That seems like a better outcome than continuing when an error happened while thinking everything succeeded?



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: