Make the sdf::Error
class compatible with other error codes/use cases
#848
Labels
sdf::Error
class compatible with other error codes/use cases
#848
Desired behavior
Currently, the
sdf::Error
class is only compatible withsdf::ErrorCode
types. It would be nice to modify thesdf::Error
class to be compatible with different error code types that may represent a different use case - for example, error codes that are specific to a SDF component (see the discussion in #836).Alternatives considered
1: extend
sdf::ErrorCode
to have different types of error codes. The drawback here is thatsdf::ErrorCode
could potentially have error codes that aren't directly related to SDF.2: create separate error classes for different use cases that wrap
sdf::Error
. This is what was proposed in #836 (comment). The drawback with this approach is that there is some code duplication and/or extra maintenance.3: Make some (or all) of the methods in
sdf::ErrorCode
virtual, so that something like approach 2 above doesn't have code duplication. The drawback with this approach is that the derived class may not want all of the functionality from thesdf::ErrorCode
class.4: Make
sdf::Error
take something like a template type instead of thesdf::ErrorCode
type. This may introduce unnecessary complexity, and would also break API/ABI.Implementation suggestion
See the alternatives considered section above for some ideas (I'm sure there are more that I did not come up with). Currently, there are no particular approaches that seem to stick out as "the best".
Additional context
See links provided above for more context. This also might be useful: https://stackoverflow.com/questions/37700365/if-youre-in-the-we-dont-use-exceptions-camp-then-how-do-you-use-the-standar/37750064#37750064
The text was updated successfully, but these errors were encountered: