Skip to content

Commit 610baa4

Browse files
committed
fix: transmit error as a string
1 parent 2e67dbb commit 610baa4

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

parse.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,8 @@ func (p *Parser) render() {
381381
Return(Nil(), Id("e")),
382382
).Else().If().Id("e").Op(":=").Qual("encoding/json", "Unmarshal").Call(Id("m").Dot("Data"), Op("&").Id("r")).Op(";").Id("e").Op("!=").Nil().Block(
383383
Return(Nil(), Id("e")),
384-
).Else().If().Id("r").Dot("Error").Op("!=").Nil().Block(
385-
Return(Nil(), Id("r").Dot("Error")),
384+
).Else().If().Id("r").Dot("Error").Op("!=").Lit("").Block(
385+
Return(Nil(), Qual("errors", "New").Call(Id("r").Dot("Error"))),
386386
).Else().Block(
387387
Return(Id("r").Dot("Data"), Nil()),
388388
),
@@ -534,7 +534,7 @@ func (p *Parser) render() {
534534
}
535535

536536
it.Op(";").Id("err").Op("!=").Nil().Block(
537-
Id("r").Dot("Error").Op("=").Id("err"),
537+
Id("r").Dot("Error").Op("=").Id("err").Dot("Error").Call(),
538538
)
539539

540540
if len(m.Results) > 1 {

types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ type Logger interface {
99
type Request struct {
1010
Subject string `json:"-"` // nats subject, used for processing only and not sent via nats
1111
Data []byte `json:"d,omitempty"` // params (on server) or result (on client)
12-
Error error `json:"e,omitempty"` // error sent from server handler
12+
Error string `json:"e,omitempty"` // error sent from server handler
1313
}

0 commit comments

Comments
 (0)