mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2025-02-23 04:38:06 +00:00
Ensure that Exec error is also logged to file
This change removes unneeded logging and renames the return error value to rerr to avoid it being aliased by local error values. Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
48d5a1cd1a
commit
c5c2ffd68f
@ -31,7 +31,7 @@ func main() {
|
||||
|
||||
// run is an entry point that allows for idiomatic handling of errors
|
||||
// when calling from the main function.
|
||||
func run(argv []string) (err error) {
|
||||
func run(argv []string) (rerr error) {
|
||||
cfg, err := getConfig()
|
||||
if err != nil {
|
||||
return fmt.Errorf("error loading config: %v", err)
|
||||
@ -43,8 +43,8 @@ func run(argv []string) (err error) {
|
||||
}
|
||||
defer func() {
|
||||
// We capture and log a returning error before closing the log file.
|
||||
if err != nil {
|
||||
logger.Errorf("Error running %v: %v", argv, err)
|
||||
if rerr != nil {
|
||||
logger.Errorf("Error running %v: %v", argv, rerr)
|
||||
}
|
||||
logger.CloseFile()
|
||||
}()
|
||||
@ -54,7 +54,6 @@ func run(argv []string) (err error) {
|
||||
return fmt.Errorf("error creating runtime: %v", err)
|
||||
}
|
||||
|
||||
logger.Printf("Running %s\n", argv[0])
|
||||
return r.Exec(argv)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user