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

What I liked about Bosst's error_code[1], which is part of the standard library now, is that it carties not just the error but the error category, and with it a machinery for categories to compare error_codes from other categories.

So as a user you could check for a generic file_not_found error, and if the underlying library uses http it could just pass on the 404 error_code with an http_category say, and your comparison would return true.

This allows you to handle very specific errors yet also allow users to handle errors in a more generic fashion in most cases.

[1]: https://www.boost.org/doc/libs/latest/libs/system/doc/html/s...



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

Search: