File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -231,36 +231,24 @@ func _recover(useParentFrame bool) interface{} {
231231 return nil
232232}
233233
234- // printPanicChain prints the full chain of panics, with annotations for
235- // recovered and repanicked entries, matching Go's output format.
236234func printPanicChain () {
237- // Collect entries into a slice (they're in reverse order).
238- entry := (* panicEntry )(task .Current ().PanicData )
235+ printPanicEntry ((* panicEntry )(task .Current ().PanicData ))
236+ }
237+
238+ func printPanicEntry (entry * panicEntry ) {
239239 if entry == nil {
240240 return
241241 }
242- // Count entries.
243- n := 0
244- for e := entry ; e != nil ; e = e .next {
245- n ++
242+ if entry .next != nil {
243+ printPanicEntry (entry .next )
244+ printstring ("\t " )
246245 }
247- // Print from oldest to newest.
248- entries := make ([]* panicEntry , n )
249- for i , e := n - 1 , entry ; e != nil ; e = e .next {
250- entries [i ] = e
251- i --
252- }
253- for i , e := range entries {
254- if i > 0 {
255- printstring ("\t " )
256- }
257- printstring ("panic: " )
258- printitf (e .value )
259- if e .recovered {
260- printstring (" [recovered]" )
261- }
262- printnl ()
246+ printstring ("panic: " )
247+ printitf (entry .value )
248+ if entry .recovered {
249+ printstring (" [recovered]" )
263250 }
251+ printnl ()
264252}
265253
266254func clearRecoveredPanicEntries () {
You can’t perform that action at this time.
0 commit comments