File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed
Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -107,13 +107,19 @@ func (e *GenkitError) Unwrap() error {
107107
108108// ToReflectionError returns a JSON-serializable representation for reflection API responses.
109109func (e * GenkitError ) ToReflectionError () ReflectionError {
110- errDetails := & ReflectionErrorDetails {}
110+ var errDetails * ReflectionErrorDetails
111111 if e .Details != nil {
112- if stackVal , ok := e .Details ["stack" ].(string ); ok {
113- errDetails .Stack = & stackVal
114- }
115- if traceVal , ok := e .Details ["traceId" ].(string ); ok {
116- errDetails .TraceID = & traceVal
112+ stackVal , stackOk := e .Details ["stack" ].(string )
113+ traceVal , traceOk := e .Details ["traceId" ].(string )
114+
115+ if stackOk || traceOk {
116+ errDetails = & ReflectionErrorDetails {}
117+ if stackOk {
118+ errDetails .Stack = & stackVal
119+ }
120+ if traceOk {
121+ errDetails .TraceID = & traceVal
122+ }
117123 }
118124 }
119125 return ReflectionError {
Original file line number Diff line number Diff line change @@ -157,8 +157,8 @@ func TestGenkitErrorToReflectionError(t *testing.T) {
157157 if re .Message != "success" {
158158 t .Errorf ("Message = %q, want %q" , re .Message , "success" )
159159 }
160- if re .Details . Stack != nil {
161- t .Error ("expected nil stack " )
160+ if re .Details != nil {
161+ t .Error ("expected nil details " )
162162 }
163163 })
164164}
You can’t perform that action at this time.
0 commit comments