Content-Length: 303208 | pFad | https://github.com/go-python/gpython/commit/4865ebff614a79ea52ab9cebc153cb7a466936cb

3A py: ExceptionInfo - check for nil · go-python/gpython@4865ebf · GitHub
Skip to content

Commit 4865ebf

Browse files
committed
py: ExceptionInfo - check for nil
1 parent 5a57a8b commit 4865ebf

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

py/exception.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ func (e *Exception) Error() string {
106106

107107
// Go error interface
108108
func (e ExceptionInfo) Error() string {
109+
if e.Value == nil {
110+
return "ExceptionInfo{<nil>}"
111+
}
109112
if exception, ok := e.Value.(*Exception); ok {
110113
return exception.Error()
111114
}
@@ -114,9 +117,17 @@ func (e ExceptionInfo) Error() string {
114117

115118
// Dump a traceback for exc to w
116119
func (exc *ExceptionInfo) TracebackDump(w io.Writer) {
120+
if exc == nil {
121+
fmt.Fprintf(w, "Traceback <nil>\n")
122+
return
123+
}
117124
fmt.Fprintf(w, "Traceback (most recent call last):\n")
118125
exc.Traceback.TracebackDump(w)
119-
fmt.Fprintf(w, "%v: %v\n", exc.Type.Name, exc.Value)
126+
name := "<nil>"
127+
if exc.Type != nil {
128+
name = exc.Type.Name
129+
}
130+
fmt.Fprintf(w, "%v: %v\n", name, exc.Value)
120131
}
121132

122133
// Test for being set

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/go-python/gpython/commit/4865ebff614a79ea52ab9cebc153cb7a466936cb

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy