Skip to content

Commit c459ac8

Browse files
committed
Map typed RPC errors and add --quiet to records get
Non-streaming RPC dispatch was collapsing every handler error to INTERNAL, hiding NOT_FOUND and SCHEMA_VIOLATION from the CLI envelope and forcing exit 4. Route through MapError so typed core errors surface with their real codes (the streaming path already did this). Also wire --quiet into records get for parity with create/update/upsert/delete.
1 parent 48a8679 commit c459ac8

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

cmd/xdb/cli/records.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ func (a *App) recordGet(ctx context.Context, cmd *cli.Command) error {
109109
return wrapRPCError("records", "get", uri, err)
110110
}
111111

112+
if cmd.Bool("quiet") {
113+
return nil
114+
}
115+
112116
return formatRawJSON(cmd, resp.Data)
113117
}
114118

@@ -240,6 +244,7 @@ func recordReadFlags() []cli.Flag {
240244
&cli.StringFlag{Name: "uri", Usage: "Record URI"},
241245
&cli.StringFlag{Name: "fields", Usage: "Comma-separated field mask"},
242246
&cli.StringFlag{Name: "output", Aliases: []string{"o"}, Usage: "Output format"},
247+
&cli.BoolFlag{Name: "quiet", Usage: "Suppress output"},
243248
}
244249
}
245250

rpc/router.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
108108
if err != nil {
109109
writeJSON(w, http.StatusOK, NewErrorResponse(
110110
rpcReq.ID,
111-
InternalError(err.Error()),
111+
MapError(err),
112112
))
113113

114114
return

0 commit comments

Comments
 (0)