mirror of
https://github.com/minio/minio.git
synced 2025-02-09 12:48:08 -05:00
Merge pull request #791 from harshavardhana/pr_out_more_changes_to_probe_to_avoid_nil_dereferences
More changes to probe to avoid nil dereferences
This commit is contained in:
commit
7f13095260
@ -78,6 +78,10 @@ func New(e error) *Error {
|
||||
// Trace records the point at which it is invoked. Stack traces are important for
|
||||
// debugging purposes.
|
||||
func (e *Error) Trace(fields ...string) *Error {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
e.lock.Lock()
|
||||
defer e.lock.Unlock()
|
||||
|
||||
@ -103,6 +107,9 @@ func (e *Error) trace(fields ...string) *Error {
|
||||
|
||||
// Untrace erases last trace entry.
|
||||
func (e *Error) Untrace() {
|
||||
if e == nil {
|
||||
return
|
||||
}
|
||||
e.lock.Lock()
|
||||
defer e.lock.Unlock()
|
||||
|
||||
@ -116,14 +123,21 @@ func (e *Error) Untrace() {
|
||||
|
||||
// Error returns error string.
|
||||
func (e *Error) Error() string {
|
||||
if e == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
return e.String()
|
||||
}
|
||||
|
||||
// String returns error message.
|
||||
func (e *Error) String() string {
|
||||
if e == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
e.lock.RLock()
|
||||
defer e.lock.RUnlock()
|
||||
|
||||
if e.e != nil {
|
||||
trace := e.e.Error() + "\n"
|
||||
for i, tp := range e.tracePoints {
|
||||
if len(tp.Env) > 0 {
|
||||
@ -142,9 +156,15 @@ func (e *Error) String() string {
|
||||
|
||||
return trace
|
||||
}
|
||||
return "<nil>"
|
||||
}
|
||||
|
||||
// JSON returns JSON formated error trace.
|
||||
func (e *Error) JSON() string {
|
||||
if e == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
|
||||
e.lock.RLock()
|
||||
defer e.lock.RUnlock()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user