You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This doesn't happen for Test_Repro2 (which calls an identical function to Test_Repro4 except the return type is error rather than a concrete type that implements error) because error is already an interface and so is not boxed.
A possible solution for this problem would be to ensure that the error check guards against the possibility that the error is nil, like so:
if err, ok := object.(error); ok && !isNil(err) {
commonRepresentation += "\n" + IndentString(err.Error(), indentation) + "\n" + indent
}
The text was updated successfully, but these errors were encountered:
Repro code here:
Test_Repro4
panics with the following traceback:What actually happens for
Test_Repro4
is that for this code,actual
is aninterface{} | *CustomError
(a boxed nil).When this is passed through to func Object(object interface{}, indentation uint) string, it passes the
object.(error)
cast and soerr.Error()
is called, which panics.This doesn't happen for
Test_Repro2
(which calls an identical function toTest_Repro4
except the return type iserror
rather than a concrete type that implements error) becauseerror
is already an interface and so is not boxed.A possible solution for this problem would be to ensure that the
error
check guards against the possibility that the error is nil, like so:The text was updated successfully, but these errors were encountered: