Skip to content

Commit

Permalink
Fix error message (#236)
Browse files Browse the repository at this point in the history
Fix error message: Instead of printing bytes in error message convert them to string.

Signed-off-by: Pritesh Bandi <pritesb@amazon.com>
  • Loading branch information
priteshbandi committed Dec 22, 2022
1 parent 6c88d3d commit c90d521
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func run(ctx context.Context, pluginName string, pluginPath string, req proto.Re
if jsonErr != nil {
return proto.RequestError{
Code: proto.ErrorCodeGeneric,
Err: fmt.Errorf("response is not in JSON format. error: %v stderr: %v", err, stderr)}
Err: fmt.Errorf("response is not in JSON format. error: %v, stderr: %s", err, string(stderr))}
}
return re
}
Expand Down
6 changes: 3 additions & 3 deletions plugin/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import (
func TestGetMetadata(t *testing.T) {
t.Run("plugin error is in invalid json format", func(t *testing.T) {
exitErr := errors.New("unknown error")
stderr := []byte("{}")
stderr := []byte("sad")
wantErr := proto.RequestError{
Code: proto.ErrorCodeGeneric,
Err: fmt.Errorf("response is not in JSON format. error: %v stderr: %v", exitErr, stderr)}
Err: fmt.Errorf("response is not in JSON format. error: %v, stderr: %s", exitErr, string(stderr))}
plugin := CLIPlugin{}
executor = testCommander{stdout: nil, stderr: stderr, err: exitErr}
_, err := plugin.GetMetadata(context.Background(), &proto.GetMetadataRequest{})
Expand All @@ -47,7 +47,7 @@ func TestGetMetadata(t *testing.T) {
stderr := []byte("")
wantErr := proto.RequestError{
Code: proto.ErrorCodeGeneric,
Err: fmt.Errorf("response is not in JSON format. error: %v stderr: %v", exitErr, stderr)}
Err: fmt.Errorf("response is not in JSON format. error: %v, stderr: %s", exitErr, string(stderr))}
plugin := CLIPlugin{}
executor = testCommander{stdout: nil, stderr: stderr, err: exitErr}
_, err := plugin.GetMetadata(context.Background(), &proto.GetMetadataRequest{})
Expand Down

0 comments on commit c90d521

Please sign in to comment.