Просмотр исходного кода

Fix: TraceNew and Tracef logged wrong caller name

Rod Hynes 6 лет назад
Родитель
Сommit
36924a10d2
1 измененных файлов с 6 добавлено и 2 удалено
  1. 6 2
      psiphon/common/errors/errors.go

+ 6 - 2
psiphon/common/errors/errors.go

@@ -35,13 +35,17 @@ import (
 // TraceNew returns a new error with the given message, wrapped with the caller
 // stack frame information.
 func TraceNew(message string) error {
-	return Trace(fmt.Errorf("%s", message))
+	err := fmt.Errorf("%s", message)
+	pc, _, line, _ := runtime.Caller(1)
+	return fmt.Errorf("%s#%d: %w", stacktrace.GetFunctionName(pc), line, err)
 }
 
 // Tracef returns a new error with the given formatted message, wrapped with
 // the caller stack frame information.
 func Tracef(format string, args ...interface{}) error {
-	return Trace(fmt.Errorf(format, args...))
+	err := fmt.Errorf(format, args...)
+	pc, _, line, _ := runtime.Caller(1)
+	return fmt.Errorf("%s#%d: %w", stacktrace.GetFunctionName(pc), line, err)
 }
 
 // Trace wraps the given error with the caller stack frame information.