Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the sdf::Error class compatible with other error codes/use cases #848

Open
adlarkin opened this issue Feb 9, 2022 · 1 comment
Open
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@adlarkin
Copy link
Contributor

adlarkin commented Feb 9, 2022

Desired behavior

Currently, the sdf::Error class is only compatible with sdf::ErrorCode types. It would be nice to modify the sdf::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 that sdf::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 the sdf::ErrorCode class.
4: Make sdf::Error take something like a template type instead of the sdf::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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants