if list[0] != uint64(i+1) {
t.Fatal("bad id")
}
- if len(list[1].(map[string]any)) != 0 {
+ if len(list[1].(string)) != 0 {
t.Fatal("has err", list[1])
}
reply, err = keks.NewDecoderFromReader(cli, nil).Decode()
if !ok {
return fmt.Errorf("keks/rpc: ReadResponseHeader: unknown id: %d", resp.Seq)
}
- e := list[1].(map[string]any)
- if len(e) > 0 {
- msg, ok := e["msg"]
- if ok {
- resp.Error = msg.(string)
- if len(resp.Error) == 0 {
- resp.Error = "unspecified"
- }
- } else {
- code, ok := e["code"]
- if ok {
- resp.Error = fmt.Sprintf("code: %d", code.(uint64))
- } else {
- resp.Error = "unspecified"
- }
- }
- }
+ resp.Error = list[1].(string)
return nil
}
+++ /dev/null
-package rpc
-
-type Error struct {
- Msg *string `keks:"msg,omitempty"`
- Code *uint64 `keks:"code,omitempty"`
-}
}
delete(sc.pending, resp.Seq)
sc.pendingM.Unlock()
- e := Error{}
- if resp.Error != "" {
- e.Msg = &resp.Error
- }
- if _, err = keks.Encode(sc.conn, []any{id, e}, nil); err != nil {
+ if _, err = keks.Encode(sc.conn, []any{id, resp.Error}, nil); err != nil {
return fmt.Errorf("keks/rpc: WriteResponse: %w", err)
}
if _, err = keks.Encode(sc.conn, data, nil); err != nil {
empty. "id" is a positive 64-bit integer, that must be unique during the
whole session's connection.
-Response object is also a LIST followed by MAP with arbitrary values.
-Response's "id" must be the same as in corresponding request. Empty
-error map means no error occurred.
+Response object is also a LIST followed by MAP with arbitrary values,
+corresponding error additional data. Response's "id" must be the same as
+in corresponding request. Empty error string means no error occurred.
<< [schemas/rpc.tcl]\r
resp {
{field . {list} len=2}
{field 0 {int} >0} {# id}
- {field 1 {with err}}
-}
-
-err {
- {field msg {str} >0 optional}
- {field code {int} >0 optional}
+ {field 1 {str}} {# error}
}