libremidi icon indicating copy to clipboard operation
libremidi copied to clipboard

feature/error_code for error handling

Open jcelerier opened this issue 1 year ago • 3 comments

Title says it all, the exception-based error handling is terrible.

jcelerier avatar Feb 24 '24 20:02 jcelerier

having some good progress here with std::error_code which looks like the error reporting system that fits this library best : feature/error_code

Many functions that did fail silently now report errors back to the caller.

jcelerier avatar Mar 06 '24 01:03 jcelerier

however there is an API break: https://en.cppreference.com/w/cpp/error/error_code/operator_bool

before, if(midi.open_port()) would return true if the port could be opened. But std::error_code uses true-y values to indicate that an error happened : the conditions have to be changed into if(midi.open_port() != std::error_code{})

jcelerier avatar Mar 06 '24 01:03 jcelerier

also investigating https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p1028r6.pdf through https://github.com/ned14/status-code ; it is a clear improvement

jcelerier avatar Mar 06 '24 02:03 jcelerier

done in master - right now it uses stdx::error until we get C++26 and std::error

jcelerier avatar Mar 10 '24 19:03 jcelerier