-
Notifications
You must be signed in to change notification settings - Fork 0
Description
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:
neofs-shared-lib/response/response.go
Lines 27 to 32 in f87a9f6
| 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.