MCPcopy Index your code
hub / github.com/dropbox/godropbox / extractFullErrorMessage

Function extractFullErrorMessage

errors/errors.go:169–198  ·  view source on GitHub ↗

Constructs full error message for a given DropboxError by traversing all of its inner errors. If includeStack is True it will also include stack trace from deepest DropboxError in the chain.

(e DropboxError, includeStack bool)

Source from the content-addressed store, hash-verified

167// all of its inner errors. If includeStack is True it will also include
168// stack trace from deepest DropboxError in the chain.
169func extractFullErrorMessage(e DropboxError, includeStack bool) string {
170 var ok bool
171 var lastDbxErr DropboxError
172 errMsg := bytes.NewBuffer(make([]byte, 0, 1024))
173
174 dbxErr := e
175 for {
176 lastDbxErr = dbxErr
177 errMsg.WriteString(dbxErr.GetMessage())
178
179 innerErr := dbxErr.Unwrap()
180 if innerErr == nil {
181 break
182 }
183 dbxErr, ok = innerErr.(DropboxError)
184 if !ok {
185 // We have reached the end and traveresed all inner errors.
186 // Add last message and exit loop.
187 errMsg.WriteString("\n")
188 errMsg.WriteString(innerErr.Error())
189 break
190 }
191 errMsg.WriteString("\n")
192 }
193 if includeStack {
194 errMsg.WriteString("\nORIGINAL STACK TRACE:\n")
195 errMsg.WriteString(lastDbxErr.GetStack())
196 }
197 return errMsg.String()
198}
199
200// Return a wrapped error or nil if there is none.
201func unwrapError(ierr error) (nerr error) {

Callers 2

GetMessageFunction · 0.85
ErrorMethod · 0.85

Calls 5

GetStackMethod · 0.95
GetMessageMethod · 0.65
UnwrapMethod · 0.65
ErrorMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected