diff --git a/client.go b/client.go index f8a6b9c..e8b0420 100644 --- a/client.go +++ b/client.go @@ -161,7 +161,7 @@ func (c *client) Call( } procedure := spec.ProcedureForPath(procedurePath) if procedure == nil { - return fmt.Errorf("no procedure for path %q", procedurePath) + return NewErrorf(CodeUnimplemented, "procedure unimplemented: %q", procedurePath) } data, err := marshalRequest(c.format, request) if err != nil { diff --git a/pluginrpc_test.go b/pluginrpc_test.go index 0e409f6..75611e8 100644 --- a/pluginrpc_test.go +++ b/pluginrpc_test.go @@ -108,6 +108,25 @@ func TestEchoError(t *testing.T) { ) } +func TestUnimplemented(t *testing.T) { + t.Parallel() + forEachDimension( + t, + func(t *testing.T, client pluginrpc.Client) { + err := client.Call( + context.Background(), + "/foo/bar", + nil, + nil, + ) + pluginrpcError := &pluginrpc.Error{} + require.Error(t, err) + require.ErrorAs(t, err, &pluginrpcError) + require.Equal(t, pluginrpc.CodeUnimplemented, pluginrpcError.Code()) + }, + ) +} + func forEachDimension(t *testing.T, f func(*testing.T, pluginrpc.Client)) { for _, format := range allTestFormats { for j, newClient := range []func(...pluginrpc.ClientOption) (pluginrpc.Client, error){newExecRunnerClient, newServerRunnerClient} {