mirror of
				https://github.com/minio/minio.git
				synced 2025-10-29 15:55:00 -04:00 
			
		
		
		
	Merge pull request #802 from abperiasamy/probe-reverse
return call stack in reverse
This commit is contained in:
		
						commit
						8463040cd1
					
				| @ -137,11 +137,14 @@ func (e *Error) String() string { | |||||||
| 
 | 
 | ||||||
| 	if e.Cause != nil { | 	if e.Cause != nil { | ||||||
| 		str := e.Cause.Error() + "\n" | 		str := e.Cause.Error() + "\n" | ||||||
| 		for i, tp := range e.CallTrace { | 		callLen := len(e.CallTrace) | ||||||
| 			if len(tp.Env) > 0 { | 		for i := callLen - 1; i >= 0; i-- { | ||||||
| 				str += fmt.Sprintf(" (%d) %s:%d %s(..) Tags: [%s]\n", i, tp.Filename, tp.Line, tp.Function, strings.Join(tp.Env["Tags"], ", ")) | 			if len(e.CallTrace[i].Env) > 0 { | ||||||
|  | 				str += fmt.Sprintf(" (%d) %s:%d %s(..) Tags: [%s]\n", | ||||||
|  | 					i, e.CallTrace[i].Filename, e.CallTrace[i].Line, e.CallTrace[i].Function, strings.Join(e.CallTrace[i].Env["Tags"], ", ")) | ||||||
| 			} else { | 			} else { | ||||||
| 				str += fmt.Sprintf(" (%d) %s:%d %s(..)\n", i, tp.Filename, tp.Line, tp.Function) | 				str += fmt.Sprintf(" (%d) %s:%d %s(..)\n", | ||||||
|  | 					i, e.CallTrace[i].Filename, e.CallTrace[i].Line, e.CallTrace[i].Function) | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -29,15 +29,23 @@ type MySuite struct{} | |||||||
| 
 | 
 | ||||||
| var _ = Suite(&MySuite{}) | var _ = Suite(&MySuite{}) | ||||||
| 
 | 
 | ||||||
| func testDummy() *probe.Error { | func testDummy0() *probe.Error { | ||||||
| 	_, e := os.Stat("this-file-cannot-exit") | 	_, e := os.Stat("this-file-cannot-exit") | ||||||
| 	es := probe.NewError(e) | 	return probe.NewError(e) | ||||||
| 	es.Trace("Important info 1", "Import into 2") | } | ||||||
| 	return es | 
 | ||||||
|  | func testDummy1() *probe.Error { | ||||||
|  | 	return testDummy0().Trace("DummyTag1") | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func testDummy2() *probe.Error { | ||||||
|  | 	return testDummy1().Trace("DummyTag2") | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (s *MySuite) TestProbe(c *C) { | func (s *MySuite) TestProbe(c *C) { | ||||||
| 	es := testDummy() | 	es := testDummy2().Trace("TopOfStack") | ||||||
|  | 	// Uncomment the following Println to visually test probe call trace. | ||||||
|  | 	// fmt.Println("Expecting a simulated error here.", es) | ||||||
| 	c.Assert(es, Not(Equals), nil) | 	c.Assert(es, Not(Equals), nil) | ||||||
| 
 | 
 | ||||||
| 	newES := es.Trace() | 	newES := es.Trace() | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user