Browse Source

Ensure ContextError doesn't turn success into error

Rod Hynes 11 years ago
parent
commit
41da3e6fc9
1 changed files with 3 additions and 0 deletions
  1. 3 0
      psiphon/utils.go

+ 3 - 0
psiphon/utils.go

@@ -77,6 +77,9 @@ func TrimError(err error) error {
 
 
 // ContextError prefixes an error message with the current function name
 // ContextError prefixes an error message with the current function name
 func ContextError(err error) error {
 func ContextError(err error) error {
+	if err == nil {
+		return nil
+	}
 	pc, _, line, _ := runtime.Caller(1)
 	pc, _, line, _ := runtime.Caller(1)
 	funcName := runtime.FuncForPC(pc).Name()
 	funcName := runtime.FuncForPC(pc).Name()
 	return fmt.Errorf("%s#%d: %s", funcName, line, err)
 	return fmt.Errorf("%s#%d: %s", funcName, line, err)