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

Use a well-defined constant Error Type(s) as Response Type #25

Open
mialbu opened this issue Feb 20, 2024 · 0 comments
Open

Use a well-defined constant Error Type(s) as Response Type #25

mialbu opened this issue Feb 20, 2024 · 0 comments

Comments

@mialbu
Copy link
Member

mialbu commented Feb 20, 2024

Problem Statement

If there's an error, the response type is dependent on the exact error type. That means, the error type could be more or less arbitrary, e.g., fmt.wrapError, fmt.Error, or others. The specific type of the error is not really useful and should be passed on in a more controlled manner along its message.

Context:

func Error(err error) *PointerResponse {
return &PointerResponse{
reflectType: reflect.TypeOf(err),
data: []byte(err.Error()),
}
}

Solution Approach

The error type should be a well-defined constant value, so that the consumer of that response struct value can easily verify that it is an error.

If needed, there could still be a more granular approach that could include multiple well-defined constant error type values. The important part of this issue is, that the consumer of the shared-lib knows exactly which types of errors it has to deal with.

@mialbu mialbu changed the title Use a well-defined Error Type as Response Type Use a well-defined constant Error Type(s) as Response Type Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant