-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
There is bug is in the generation code, specifically the way we inline the private error type rather than naming it. Take the example of the following definition:
types:
definitions:
errors:
MyError:
code: CUSTOM_SERVER
namespace: MyNamespace
safe-args:
code: integer
message: string
The above definition would generate roughly the following:
type myError {
Code int
Message string
}
type MyError struct {
errorInstanceID uuid.UUID
myError
cause error
stack werror.StackTrace
}
The collision occurs on the generated SafeParams
method.
// safeParams returns a set of named safe parameters detailing this particular error instance.
func (e *MyError) safeParams() map[string]interface{} {
return map[string]interface{}{"code": e.Code, "message": e.Message, "errorInstanceId": e.errorInstanceID}
}
Because Code
and Message
are also methods on MyError
, this actually returns functions rather than the values stored on myError
.
Think the fix is just to name the internal error type on the exported error type - I don't see any reason this needs to be inlined.
Metadata
Metadata
Assignees
Labels
No labels