PragmaTwice commented on PR #768:
URL: 
https://github.com/apache/incubator-kvrocks/pull/768#issuecomment-1210588221

   > @PragmaTwice
   > 
   > If using exception to report error instead of status, we don't need Status 
and this StatusOr at all.
   > 
   > What is the better way to report error in C++? error code or exception? 
Here are same posts to discuss this question:
   > 
   > * https://isocpp.org/wiki/faq/exceptions
   > * 
https://stackoverflow.com/questions/253314/conventions-for-exceptions-or-error-codes
   
   Hi @wy-ei , a large part of C++ projects do not use exception as the mainly 
error handling method (but use it while some fatal or very accidental error 
occurred) since exception is relatively expensive in bad path (or say, failure 
path, maybe x10 - x20 slower than conditional jumping, but zero-cost on happy 
path)[1-2], like all Google products, LLVM projects, etc.
   
   Another defect is that C++ does not have checked exception, this makes 
exception flows not easy to maintain. So I don't have a strong desire to use 
exceptions.
   
   [1] https://pspdfkit.com/blog/2020/performance-overhead-of-exceptions-in-cpp
   [2] https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2544r0.html


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to