I'm developing a library that talks to a remote system and while it returns a finite and known number of error codes, the messages may change in unpredictable ways.
So I'm exploring std::error_code
as a way to provide users of my library a way to handle errors native to C++, instead of rolling out my own code. I cannot throw exceptions.
Tutorials on the use of std::error_category
always show that a static instance is used with hardcoded messages being returned depending on the error code.
But what if we have dynamic messages that cannot be cached? How can we link a specific message to a specific instance of std::error_code
?
Aucun commentaire:
Enregistrer un commentaire