diff --git a/cli/cli.go b/cli/cli.go index 033a594..045f8df 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -142,8 +142,9 @@ func (c *CLI) unmarshalRequest(request plugin.Request) error { if err := request.Validate(); err != nil { c.logger.Errorf("%s validation error :%v", reflect.TypeOf(request), err) - if e, ok := err.(*plugin.Error); ok { - return plugin.NewValidationErrorf("%s: %s", plugin.ErrorMsgMalformedInput, e.Message) + var plError *plugin.Error + if errors.As(err, &plError) { + return plugin.NewValidationErrorf("%s: %s", plugin.ErrorMsgMalformedInput, plError.Message) } return plugin.NewValidationErrorf("%s", plugin.ErrorMsgMalformedInput) } diff --git a/plugin/errors.go b/plugin/errors.go index 6e6297f..575a257 100644 --- a/plugin/errors.go +++ b/plugin/errors.go @@ -34,8 +34,7 @@ const ( ErrorMsgMalformedOutputFmt string = "Failed to generate response. Error: %s" ) -// Error is used when the signature associated is no longer -// valid. +// Error is used to return a well-formed error response as per NotaryProject specification. type Error struct { ErrCode ErrorCode `json:"errorCode"` Message string `json:"errorMessage,omitempty"`