Skip to content

Commit

Permalink
errorStackTrace support
Browse files Browse the repository at this point in the history
  • Loading branch information
klaidliadon committed Apr 23, 2024
1 parent f912214 commit 3cc5f5f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
6 changes: 5 additions & 1 deletion _examples/golang-basics/example.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion _examples/golang-imports/api.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion errors.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@ func (e WebRPCError) WithCause(cause error) WebRPCError {
}

func (e WebRPCError) WithCausef(fmt string, args ...interface{}) WebRPCError {
return e.WithCause(fmt.Errorf(msg, args...))
cause := fmt.Errorf(fmt, args...)
err := e
err.cause = cause
err.Cause = cause.Error()
{{- if $opts.errorStackTrace }}
runtime.Callers(1, err.frame.frames[:])
{{- end}}
return err
}

// Deprecated: Use .WithCause() method on WebRPCError.
Expand Down

0 comments on commit 3cc5f5f

Please sign in to comment.