[#552] cmd/node: Implement error checker with details
Implement function `fatalOnErrDetails` similar to `fatalOnErr` but accepting string details that are written to log output. Use the function everywhere in application code without wrapping in an if-else statement. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
ead4513feb
commit
6b1916a529
3 changed files with 13 additions and 13 deletions
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/misc"
|
||||
|
@ -11,12 +12,20 @@ import (
|
|||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// prints err to standard logger and calls os.Exit(1).
|
||||
func fatalOnErr(err error) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// prints err with details to standard logger and calls os.Exit(1).
|
||||
func fatalOnErrDetails(details string, err error) {
|
||||
if err != nil {
|
||||
log.Fatal(fmt.Errorf("%s: %w", details, err))
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
configFile := flag.String("config", "", "path to config")
|
||||
flag.Parse()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue