Skip to content

Commit 4865ebf

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

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy