breese / trial.protocol

Network wire protocols
11 stars 4 forks source link

Use error specializations thoroughly #40

Closed vinipsmaker closed 4 years ago

vinipsmaker commented 4 years ago

There is a topic from your blog:

Better yet, define an mpg123::error exception that inherits from std::system_error, so exceptions from the mpg123 adapter can be distinguished from other system_error exceptions in the try-catch block.

http://breese.github.io/2017/05/12/customizing-error-codes.html

I just noticed that you use this trick in the library (and then remembered your blog post):

include/trial/protocol/json/error.hpp:class error : public std::system_error

However, the PR for the skip algorithm I've sent previously (I was playing with json::partial::skip() lately) doesn't follow this trick and throws system_error directly:

https://github.com/breese/trial.protocol/blob/5e5c939303ad69c6db9451caa17fe37e45cc476a/include/trial/protocol/json/partial/skip.hpp#L79

breese commented 4 years ago

Good catch. Fixed in 4bdf90747944f24b61aa9dbde92d8f6dd6758c94