Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch adds functionality to nng::exception, making it inherit from and implement
std::system_error
, the standard interface for exceptions based on a numeric code which can be translated into a string name.This allows:
std::error_code
andstd::error_condition
.No existing functionality is changed or removed.
The most complicated detail of this patch is the translation to POSIX error codes. Although the standard does not mandate the use of the generic category in
default_error_condition
, it allows for greater practical similarity with other libraries and can be achieved with only minor wrinkles.Mappings are implemented as described in #25 where I proposed this functionality. Notably, I'm not sure whether I'm handling NNG_ESYSERR-flagged codes correctly in
default_error_condition
.Here's the result of a diagnostic test mapping error codes 0-31, 1000 (EINTERNAL) and ESYSERR|
0xC0000005
to their generic equivalents. This was compiled on MSVC: