Quellcode durchsuchen

Fix: additional stack info was redundant

Rod Hynes vor 9 Jahren
Ursprung
Commit
663d0b2494
2 geänderte Dateien mit 4 neuen und 15 gelöschten Zeilen
  1. 1 1
      psiphon/server/api.go
  2. 3 14
      psiphon/server/utils.go

+ 1 - 1
psiphon/server/api.go

@@ -99,7 +99,7 @@ func dispatchAPIRequestHandler(
 	defer func() {
 		if e := recover(); e != nil {
 			if intentionalPanic, ok := e.(IntentionalPanicError); ok {
-				panic(intentionalPanic.AddStack(debug.Stack()))
+				panic(intentionalPanic)
 			} else {
 				log.LogPanicRecover(e, debug.Stack())
 				reterr = common.ContextError(errors.New("request handler panic"))

+ 3 - 14
psiphon/server/utils.go

@@ -137,8 +137,9 @@ type IntentionalPanicError struct {
 }
 
 // NewIntentionalPanicError creates a new IntentionalPanicError.
-func NewIntentionalPanicError(message string) error {
-	return IntentionalPanicError{message: message}
+func NewIntentionalPanicError(errorMessage string) error {
+	return IntentionalPanicError{
+		message: fmt.Sprintf("intentional panic error: %s", errorMessage)}
 }
 
 // Error implements the error interface.
@@ -146,18 +147,6 @@ func (err IntentionalPanicError) Error() string {
 	return err.message
 }
 
-// AddStack creates a new IntentionalPanicError which
-// records the given stack. When a IntentionalPanicError is
-// recovered, call AddStack with the debug.Stack() at the
-// point of recovery, and panic with the resulting
-// IntentionalPanicError.
-func (err IntentionalPanicError) AddStack(debugStack []byte) error {
-	return NewIntentionalPanicError(
-		fmt.Sprintf("intentional panic error: %s\nstack: %s\n",
-			err.Error(),
-			string(debugStack)))
-}
-
 // PanickingLogWriter wraps an io.Writer and intentionally
 // panics when a Write() fails.
 type PanickingLogWriter struct {