mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-11-05 01:40:10 +00:00
Harvey Tindall
b538922c05
Sanitization means change anything in double quotes to "CENSORED". A notice is included telling the user to check for themselves as well.
24 lines
469 B
Go
24 lines
469 B
Go
package common
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
)
|
|
|
|
// TimeoutHandler recovers from an http timeout or panic.
|
|
type TimeoutHandler func()
|
|
|
|
// NewTimeoutHandler returns a new Timeout handler.
|
|
func NewTimeoutHandler(name, addr string, noFail bool) TimeoutHandler {
|
|
return func() {
|
|
if r := recover(); r != nil {
|
|
out := fmt.Sprintf("Failed to authenticate with %s @ \"%s\": Timed out", name, addr)
|
|
if noFail {
|
|
log.Print(out)
|
|
} else {
|
|
log.Fatalf(out)
|
|
}
|
|
}
|
|
}
|
|
}
|