mirror of
https://github.com/minio/minio.git
synced 2025-11-08 21:24:55 -05:00
Remove panic() and handle it appropriately (#5807)
This is an effort to remove panic from the source. Add a new call called CriticialIf, that calls LogIf and exits. Replace panics with one of CriticalIf, FatalIf and a return of error.
This commit is contained in:
@@ -314,7 +314,19 @@ func LogIf(ctx context.Context, err error) {
|
||||
fmt.Println(output)
|
||||
}
|
||||
|
||||
// CriticalIf :
|
||||
// Like LogIf with exit
|
||||
// It'll be called for fatal error conditions during run-time
|
||||
func CriticalIf(ctx context.Context, err error) {
|
||||
if err != nil {
|
||||
LogIf(ctx, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
// FatalIf :
|
||||
// Just fatal error message, no stack trace
|
||||
// It'll be called for input validation failures
|
||||
func FatalIf(err error, msg string, data ...interface{}) {
|
||||
if err != nil {
|
||||
if msg != "" {
|
||||
|
||||
Reference in New Issue
Block a user