all: Handle errors opening db/creating file-set (ref #5907) (#7150)

This commit is contained in:
Simon Frei
2020-12-21 12:59:22 +01:00
committed by GitHub
parent b5de49917c
commit 78bd0341a8
25 changed files with 542 additions and 396 deletions
+14
View File
@@ -8,6 +8,7 @@ package util
import (
"context"
"errors"
"fmt"
"net"
"net/url"
@@ -262,6 +263,19 @@ type FatalErr struct {
Status ExitStatus
}
// AsFatalErr wraps the given error creating a FatalErr. If the given error
// already is of type FatalErr, it is not wrapped again.
func AsFatalErr(err error, status ExitStatus) *FatalErr {
var ferr *FatalErr
if errors.As(err, &ferr) {
return ferr
}
return &FatalErr{
Err: err,
Status: status,
}
}
func (e *FatalErr) Error() string {
return e.Err.Error()
}