diff --git a/src/cmds/restic/cmd_backup.go b/src/cmds/restic/cmd_backup.go index 38f6fcf7..dc07be01 100644 --- a/src/cmds/restic/cmd_backup.go +++ b/src/cmds/restic/cmd_backup.go @@ -13,7 +13,7 @@ import ( "strings" "time" - "github.com/pkg/errors" + "restic/errors" "golang.org/x/crypto/ssh/terminal" ) @@ -232,7 +232,7 @@ func filterExisting(items []string) (result []string, err error) { } if len(result) == 0 { - return nil, restic.Fatal("all target directories/files do not exist") + return nil, errors.Fatal("all target directories/files do not exist") } return @@ -240,7 +240,7 @@ func filterExisting(items []string) (result []string, err error) { func (cmd CmdBackup) readFromStdin(args []string) error { if len(args) != 0 { - return restic.Fatalf("when reading from stdin, no additional files can be specified") + return errors.Fatalf("when reading from stdin, no additional files can be specified") } repo, err := cmd.global.OpenRepository() @@ -274,7 +274,7 @@ func (cmd CmdBackup) Execute(args []string) error { } if len(args) == 0 { - return restic.Fatalf("wrong number of parameters, Usage: %s", cmd.Usage()) + return errors.Fatalf("wrong number of parameters, Usage: %s", cmd.Usage()) } target := make([]string, 0, len(args)) @@ -312,7 +312,7 @@ func (cmd CmdBackup) Execute(args []string) error { if !cmd.Force && cmd.Parent != "" { id, err := restic.FindSnapshot(repo, cmd.Parent) if err != nil { - return restic.Fatalf("invalid id %q: %v", cmd.Parent, err) + return errors.Fatalf("invalid id %q: %v", cmd.Parent, err) } parentSnapshotID = &id diff --git a/src/cmds/restic/cmd_cat.go b/src/cmds/restic/cmd_cat.go index f99d93e7..51fb2f69 100644 --- a/src/cmds/restic/cmd_cat.go +++ b/src/cmds/restic/cmd_cat.go @@ -8,6 +8,7 @@ import ( "restic" "restic/backend" "restic/debug" + "restic/errors" "restic/repository" ) @@ -31,7 +32,7 @@ func (cmd CmdCat) Usage() string { func (cmd CmdCat) Execute(args []string) error { if len(args) < 1 || (args[0] != "masterkey" && args[0] != "config" && len(args) != 2) { - return restic.Fatalf("type or ID not specified, Usage: %s", cmd.Usage()) + return errors.Fatalf("type or ID not specified, Usage: %s", cmd.Usage()) } repo, err := cmd.global.OpenRepository() @@ -52,7 +53,7 @@ func (cmd CmdCat) Execute(args []string) error { id, err = restic.ParseID(args[1]) if err != nil { if tpe != "snapshot" { - return restic.Fatalf("unable to parse ID: %v\n", err) + return errors.Fatalf("unable to parse ID: %v\n", err) } // find snapshot id with prefix @@ -181,7 +182,7 @@ func (cmd CmdCat) Execute(args []string) error { return err } - return restic.Fatal("blob not found") + return errors.Fatal("blob not found") case "tree": debug.Log("cat", "cat tree %v", id.Str()) @@ -202,6 +203,6 @@ func (cmd CmdCat) Execute(args []string) error { return nil default: - return restic.Fatal("invalid type") + return errors.Fatal("invalid type") } } diff --git a/src/cmds/restic/cmd_check.go b/src/cmds/restic/cmd_check.go index a151fc93..cd2fc409 100644 --- a/src/cmds/restic/cmd_check.go +++ b/src/cmds/restic/cmd_check.go @@ -9,6 +9,7 @@ import ( "restic" "restic/checker" + "restic/errors" ) type CmdCheck struct { @@ -65,7 +66,7 @@ func (cmd CmdCheck) newReadProgress(todo restic.Stat) *restic.Progress { func (cmd CmdCheck) Execute(args []string) error { if len(args) != 0 { - return restic.Fatal("check has no arguments") + return errors.Fatal("check has no arguments") } repo, err := cmd.global.OpenRepository() @@ -103,7 +104,7 @@ func (cmd CmdCheck) Execute(args []string) error { for _, err := range errs { cmd.global.Warnf("error: %v\n", err) } - return restic.Fatal("LoadIndex returned errors") + return errors.Fatal("LoadIndex returned errors") } done := make(chan struct{}) @@ -158,7 +159,7 @@ func (cmd CmdCheck) Execute(args []string) error { } if errorsFound { - return restic.Fatal("repository contains errors") + return errors.Fatal("repository contains errors") } return nil } diff --git a/src/cmds/restic/cmd_dump.go b/src/cmds/restic/cmd_dump.go index 5dc0247e..f29aff90 100644 --- a/src/cmds/restic/cmd_dump.go +++ b/src/cmds/restic/cmd_dump.go @@ -9,6 +9,7 @@ import ( "os" "restic" + "restic/errors" "restic/pack" "restic/repository" @@ -170,7 +171,7 @@ func (cmd CmdDump) DumpIndexes() error { func (cmd CmdDump) Execute(args []string) error { if len(args) != 1 { - return restic.Fatalf("type not specified, Usage: %s", cmd.Usage()) + return errors.Fatalf("type not specified, Usage: %s", cmd.Usage()) } repo, err := cmd.global.OpenRepository() @@ -214,6 +215,6 @@ func (cmd CmdDump) Execute(args []string) error { return nil default: - return restic.Fatalf("no such type %q", tpe) + return errors.Fatalf("no such type %q", tpe) } } diff --git a/src/cmds/restic/cmd_find.go b/src/cmds/restic/cmd_find.go index 96d31dd6..24258d51 100644 --- a/src/cmds/restic/cmd_find.go +++ b/src/cmds/restic/cmd_find.go @@ -6,6 +6,7 @@ import ( "restic" "restic/debug" + "restic/errors" "restic/repository" ) @@ -55,7 +56,7 @@ func parseTime(str string) (time.Time, error) { } } - return time.Time{}, restic.Fatalf("unable to parse time: %q", str) + return time.Time{}, errors.Fatalf("unable to parse time: %q", str) } func (c CmdFind) findInTree(repo *repository.Repository, id restic.ID, path string) ([]findResult, error) { @@ -135,7 +136,7 @@ func (CmdFind) Usage() string { func (c CmdFind) Execute(args []string) error { if len(args) != 1 { - return restic.Fatalf("wrong number of arguments, Usage: %s", c.Usage()) + return errors.Fatalf("wrong number of arguments, Usage: %s", c.Usage()) } var err error @@ -175,7 +176,7 @@ func (c CmdFind) Execute(args []string) error { if c.Snapshot != "" { snapshotID, err := restic.FindSnapshot(repo, c.Snapshot) if err != nil { - return restic.Fatalf("invalid id %q: %v", args[1], err) + return errors.Fatalf("invalid id %q: %v", args[1], err) } return c.findInSnapshot(repo, snapshotID) diff --git a/src/cmds/restic/cmd_init.go b/src/cmds/restic/cmd_init.go index 3e68ebde..39b8cd2f 100644 --- a/src/cmds/restic/cmd_init.go +++ b/src/cmds/restic/cmd_init.go @@ -1,7 +1,7 @@ package main import ( - "restic" + "restic/errors" "restic/repository" ) @@ -11,7 +11,7 @@ type CmdInit struct { func (cmd CmdInit) Execute(args []string) error { if cmd.global.Repo == "" { - return restic.Fatal("Please specify repository location (-r)") + return errors.Fatal("Please specify repository location (-r)") } be, err := create(cmd.global.Repo) diff --git a/src/cmds/restic/cmd_key.go b/src/cmds/restic/cmd_key.go index 629f5ddf..84801815 100644 --- a/src/cmds/restic/cmd_key.go +++ b/src/cmds/restic/cmd_key.go @@ -4,6 +4,7 @@ import ( "fmt" "restic" + "restic/errors" "restic/repository" ) @@ -68,7 +69,7 @@ func (cmd CmdKey) getNewPassword() string { func (cmd CmdKey) addKey(repo *repository.Repository) error { id, err := repository.AddKey(repo, cmd.getNewPassword(), repo.Key()) if err != nil { - return restic.Fatalf("creating new key failed: %v\n", err) + return errors.Fatalf("creating new key failed: %v\n", err) } cmd.global.Verbosef("saved new key as %s\n", id) @@ -78,7 +79,7 @@ func (cmd CmdKey) addKey(repo *repository.Repository) error { func (cmd CmdKey) deleteKey(repo *repository.Repository, name string) error { if name == repo.KeyName() { - return restic.Fatal("refusing to remove key currently used to access repository") + return errors.Fatal("refusing to remove key currently used to access repository") } err := repo.Backend().Remove(restic.KeyFile, name) @@ -93,7 +94,7 @@ func (cmd CmdKey) deleteKey(repo *repository.Repository, name string) error { func (cmd CmdKey) changePassword(repo *repository.Repository) error { id, err := repository.AddKey(repo, cmd.getNewPassword(), repo.Key()) if err != nil { - return restic.Fatalf("creating new key failed: %v\n", err) + return errors.Fatalf("creating new key failed: %v\n", err) } err = repo.Backend().Remove(restic.KeyFile, repo.KeyName()) @@ -112,7 +113,7 @@ func (cmd CmdKey) Usage() string { func (cmd CmdKey) Execute(args []string) error { if len(args) < 1 || (args[0] == "rm" && len(args) != 2) { - return restic.Fatalf("wrong number of arguments, Usage: %s", cmd.Usage()) + return errors.Fatalf("wrong number of arguments, Usage: %s", cmd.Usage()) } repo, err := cmd.global.OpenRepository() diff --git a/src/cmds/restic/cmd_list.go b/src/cmds/restic/cmd_list.go index b208e3ee..a17d5ce6 100644 --- a/src/cmds/restic/cmd_list.go +++ b/src/cmds/restic/cmd_list.go @@ -1,6 +1,9 @@ package main -import "restic" +import ( + "restic" + "restic/errors" +) type CmdList struct { global *GlobalOptions @@ -22,7 +25,7 @@ func (cmd CmdList) Usage() string { func (cmd CmdList) Execute(args []string) error { if len(args) != 1 { - return restic.Fatalf("type not specified, Usage: %s", cmd.Usage()) + return errors.Fatalf("type not specified, Usage: %s", cmd.Usage()) } repo, err := cmd.global.OpenRepository() @@ -51,7 +54,7 @@ func (cmd CmdList) Execute(args []string) error { case "locks": t = restic.LockFile default: - return restic.Fatal("invalid type") + return errors.Fatal("invalid type") } for id := range repo.List(t, nil) { diff --git a/src/cmds/restic/cmd_ls.go b/src/cmds/restic/cmd_ls.go index d875e58e..733f424b 100644 --- a/src/cmds/restic/cmd_ls.go +++ b/src/cmds/restic/cmd_ls.go @@ -6,6 +6,7 @@ import ( "path/filepath" "restic" + "restic/errors" "restic/repository" ) @@ -71,7 +72,7 @@ func (cmd CmdLs) Usage() string { func (cmd CmdLs) Execute(args []string) error { if len(args) < 1 || len(args) > 2 { - return restic.Fatalf("wrong number of arguments, Usage: %s", cmd.Usage()) + return errors.Fatalf("wrong number of arguments, Usage: %s", cmd.Usage()) } repo, err := cmd.global.OpenRepository() diff --git a/src/cmds/restic/cmd_mount.go b/src/cmds/restic/cmd_mount.go index 36a2ce99..e25306e3 100644 --- a/src/cmds/restic/cmd_mount.go +++ b/src/cmds/restic/cmd_mount.go @@ -5,9 +5,8 @@ package main import ( "os" - "restic" - "github.com/pkg/errors" + "restic/errors" resticfs "restic/fs" "restic/fuse" @@ -44,7 +43,7 @@ func (cmd CmdMount) Usage() string { func (cmd CmdMount) Execute(args []string) error { if len(args) == 0 { - return restic.Fatalf("wrong number of parameters, Usage: %s", cmd.Usage()) + return errors.Fatalf("wrong number of parameters, Usage: %s", cmd.Usage()) } repo, err := cmd.global.OpenRepository() diff --git a/src/cmds/restic/cmd_prune.go b/src/cmds/restic/cmd_prune.go index c21cab16..4fa8ba0d 100644 --- a/src/cmds/restic/cmd_prune.go +++ b/src/cmds/restic/cmd_prune.go @@ -5,6 +5,7 @@ import ( "os" "restic" "restic/debug" + "restic/errors" "restic/index" "restic/repository" "time" @@ -189,7 +190,7 @@ nextPack: removePacks.Insert(packID) if !rewritePacks.Has(packID) { - return restic.Fatalf("pack %v is unneeded, but not contained in rewritePacks", packID.Str()) + return errors.Fatalf("pack %v is unneeded, but not contained in rewritePacks", packID.Str()) } rewritePacks.Delete(packID) diff --git a/src/cmds/restic/cmd_restore.go b/src/cmds/restic/cmd_restore.go index 1a55cdb4..88099b67 100644 --- a/src/cmds/restic/cmd_restore.go +++ b/src/cmds/restic/cmd_restore.go @@ -3,6 +3,7 @@ package main import ( "restic" "restic/debug" + "restic/errors" "restic/filter" ) @@ -32,15 +33,15 @@ func (cmd CmdRestore) Usage() string { func (cmd CmdRestore) Execute(args []string) error { if len(args) != 1 { - return restic.Fatalf("wrong number of arguments, Usage: %s", cmd.Usage()) + return errors.Fatalf("wrong number of arguments, Usage: %s", cmd.Usage()) } if cmd.Target == "" { - return restic.Fatal("please specify a directory to restore to (--target)") + return errors.Fatal("please specify a directory to restore to (--target)") } if len(cmd.Exclude) > 0 && len(cmd.Include) > 0 { - return restic.Fatal("exclude and include patterns are mutually exclusive") + return errors.Fatal("exclude and include patterns are mutually exclusive") } snapshotIDString := args[0] diff --git a/src/cmds/restic/cmd_snapshots.go b/src/cmds/restic/cmd_snapshots.go index 23f9eb70..d7bc4e65 100644 --- a/src/cmds/restic/cmd_snapshots.go +++ b/src/cmds/restic/cmd_snapshots.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "os" + "restic/errors" "sort" "strings" @@ -69,7 +70,7 @@ func (cmd CmdSnapshots) Usage() string { func (cmd CmdSnapshots) Execute(args []string) error { if len(args) != 0 { - return restic.Fatalf("wrong number of arguments, usage: %s", cmd.Usage()) + return errors.Fatalf("wrong number of arguments, usage: %s", cmd.Usage()) } repo, err := cmd.global.OpenRepository() diff --git a/src/cmds/restic/global.go b/src/cmds/restic/global.go index b7eff3e4..ee4255f7 100644 --- a/src/cmds/restic/global.go +++ b/src/cmds/restic/global.go @@ -17,8 +17,9 @@ import ( "restic/location" "restic/repository" + "restic/errors" + "github.com/jessevdk/go-flags" - "github.com/pkg/errors" "golang.org/x/crypto/ssh/terminal" ) @@ -246,7 +247,7 @@ const maxKeys = 20 // OpenRepository reads the password and opens the repository. func (o GlobalOptions) OpenRepository() (*repository.Repository, error) { if o.Repo == "" { - return nil, restic.Fatal("Please specify repository location (-r)") + return nil, errors.Fatal("Please specify repository location (-r)") } be, err := open(o.Repo) @@ -262,7 +263,7 @@ func (o GlobalOptions) OpenRepository() (*repository.Repository, error) { err = s.SearchKey(o.password, maxKeys) if err != nil { - return nil, restic.Fatalf("unable to open repo: %v", err) + return nil, errors.Fatalf("unable to open repo: %v", err) } return s, nil @@ -300,7 +301,7 @@ func open(s string) (restic.Backend, error) { } debug.Log("open", "invalid repository location: %v", s) - return nil, restic.Fatalf("invalid scheme %q", loc.Scheme) + return nil, errors.Fatalf("invalid scheme %q", loc.Scheme) } // Create the backend specified by URI. @@ -335,5 +336,5 @@ func create(s string) (restic.Backend, error) { } debug.Log("open", "invalid repository scheme: %v", s) - return nil, restic.Fatalf("invalid scheme %q", loc.Scheme) + return nil, errors.Fatalf("invalid scheme %q", loc.Scheme) } diff --git a/src/cmds/restic/integration_fuse_test.go b/src/cmds/restic/integration_fuse_test.go index 857f6736..a106d035 100644 --- a/src/cmds/restic/integration_fuse_test.go +++ b/src/cmds/restic/integration_fuse_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/pkg/errors" + "restic/errors" "restic" "restic/repository" @@ -50,7 +50,7 @@ func waitForMount(dir string) error { time.Sleep(mountSleep) } - return restic.Fatalf("subdir %q of dir %s never appeared", mountTestSubdir, dir) + return errors.Fatalf("subdir %q of dir %s never appeared", mountTestSubdir, dir) } func cmdMount(t testing.TB, global GlobalOptions, dir string, ready, done chan struct{}) { diff --git a/src/cmds/restic/integration_test.go b/src/cmds/restic/integration_test.go index 3a3c53e6..4a737a6a 100644 --- a/src/cmds/restic/integration_test.go +++ b/src/cmds/restic/integration_test.go @@ -16,7 +16,7 @@ import ( "testing" "time" - "github.com/pkg/errors" + "restic/errors" "restic/debug" "restic/filter" @@ -582,7 +582,7 @@ func testFileSize(filename string, size int64) error { } if fi.Size() != size { - return restic.Fatalf("wrong file size for %v: expected %v, got %v", filename, size, fi.Size()) + return errors.Fatalf("wrong file size for %v: expected %v, got %v", filename, size, fi.Size()) } return nil diff --git a/src/cmds/restic/main.go b/src/cmds/restic/main.go index 5ad0ab12..6477c1e6 100644 --- a/src/cmds/restic/main.go +++ b/src/cmds/restic/main.go @@ -7,8 +7,9 @@ import ( "restic/debug" "runtime" + "restic/errors" + "github.com/jessevdk/go-flags" - "github.com/pkg/errors" ) func init() { @@ -42,7 +43,7 @@ func main() { switch { case restic.IsAlreadyLocked(errors.Cause(err)): fmt.Fprintf(os.Stderr, "%v\nthe `unlock` command can be used to remove stale locks\n", err) - case restic.IsFatal(errors.Cause(err)): + case errors.IsFatal(errors.Cause(err)): fmt.Fprintf(os.Stderr, "%v\n", err) case err != nil: fmt.Fprintf(os.Stderr, "%+v\n", err) diff --git a/src/restic/archiver/archive_reader.go b/src/restic/archiver/archive_reader.go index 0ddefd15..2a184ee4 100644 --- a/src/restic/archiver/archive_reader.go +++ b/src/restic/archiver/archive_reader.go @@ -7,8 +7,8 @@ import ( "restic/debug" "time" - "github.com/pkg/errors" "github.com/restic/chunker" + "restic/errors" ) // saveTreeJSON stores a tree in the repository. diff --git a/src/restic/archiver/archiver.go b/src/restic/archiver/archiver.go index 9cbb34a0..99c91a39 100644 --- a/src/restic/archiver/archiver.go +++ b/src/restic/archiver/archiver.go @@ -11,7 +11,7 @@ import ( "sync" "time" - "github.com/pkg/errors" + "restic/errors" "restic/debug" "restic/fs" diff --git a/src/restic/archiver/archiver_duplication_test.go b/src/restic/archiver/archiver_duplication_test.go index 9f0867d5..aadfc590 100644 --- a/src/restic/archiver/archiver_duplication_test.go +++ b/src/restic/archiver/archiver_duplication_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/pkg/errors" + "restic/errors" "restic" "restic/archiver" diff --git a/src/restic/archiver/archiver_test.go b/src/restic/archiver/archiver_test.go index 176a0180..1d43254c 100644 --- a/src/restic/archiver/archiver_test.go +++ b/src/restic/archiver/archiver_test.go @@ -12,8 +12,8 @@ import ( "restic/crypto" . "restic/test" - "github.com/pkg/errors" "github.com/restic/chunker" + "restic/errors" ) var testPol = chunker.Pol(0x3DA3358B4DC173) diff --git a/src/restic/backend/local/config.go b/src/restic/backend/local/config.go index a430f9de..8a5c67a2 100644 --- a/src/restic/backend/local/config.go +++ b/src/restic/backend/local/config.go @@ -3,7 +3,7 @@ package local import ( "strings" - "github.com/pkg/errors" + "restic/errors" ) // ParseConfig parses a local backend config. diff --git a/src/restic/backend/local/local.go b/src/restic/backend/local/local.go index 4cfd4de9..1b76e31e 100644 --- a/src/restic/backend/local/local.go +++ b/src/restic/backend/local/local.go @@ -7,7 +7,7 @@ import ( "path/filepath" "restic" - "github.com/pkg/errors" + "restic/errors" "restic/backend" "restic/debug" diff --git a/src/restic/backend/mem/mem_backend.go b/src/restic/backend/mem/mem_backend.go index 4d1ac49a..d8885de4 100644 --- a/src/restic/backend/mem/mem_backend.go +++ b/src/restic/backend/mem/mem_backend.go @@ -5,7 +5,7 @@ import ( "restic" "sync" - "github.com/pkg/errors" + "restic/errors" "restic/debug" ) diff --git a/src/restic/backend/mem/mem_backend_test.go b/src/restic/backend/mem/mem_backend_test.go index 310f4b91..75b65f4c 100644 --- a/src/restic/backend/mem/mem_backend_test.go +++ b/src/restic/backend/mem/mem_backend_test.go @@ -3,7 +3,7 @@ package mem_test import ( "restic" - "github.com/pkg/errors" + "restic/errors" "restic/backend/mem" "restic/backend/test" diff --git a/src/restic/backend/rest/config.go b/src/restic/backend/rest/config.go index e5903107..929fda12 100644 --- a/src/restic/backend/rest/config.go +++ b/src/restic/backend/rest/config.go @@ -4,7 +4,7 @@ import ( "net/url" "strings" - "github.com/pkg/errors" + "restic/errors" ) // Config contains all configuration necessary to connect to a REST server. diff --git a/src/restic/backend/rest/rest.go b/src/restic/backend/rest/rest.go index 040faac9..ce1d25db 100644 --- a/src/restic/backend/rest/rest.go +++ b/src/restic/backend/rest/rest.go @@ -11,7 +11,7 @@ import ( "restic" "strings" - "github.com/pkg/errors" + "restic/errors" "restic/backend" ) diff --git a/src/restic/backend/rest/rest_test.go b/src/restic/backend/rest/rest_test.go index 81c64f48..2e7095b2 100644 --- a/src/restic/backend/rest/rest_test.go +++ b/src/restic/backend/rest/rest_test.go @@ -6,7 +6,7 @@ import ( "os" "restic" - "github.com/pkg/errors" + "restic/errors" "restic/backend/rest" "restic/backend/test" diff --git a/src/restic/backend/s3/config.go b/src/restic/backend/s3/config.go index 4eda2b0e..2df02b58 100644 --- a/src/restic/backend/s3/config.go +++ b/src/restic/backend/s3/config.go @@ -5,7 +5,7 @@ import ( "path" "strings" - "github.com/pkg/errors" + "restic/errors" ) // Config contains all configuration necessary to connect to an s3 compatible diff --git a/src/restic/backend/s3/s3.go b/src/restic/backend/s3/s3.go index 3af65645..b9f29b6b 100644 --- a/src/restic/backend/s3/s3.go +++ b/src/restic/backend/s3/s3.go @@ -6,7 +6,7 @@ import ( "restic" "strings" - "github.com/pkg/errors" + "restic/errors" "github.com/minio/minio-go" diff --git a/src/restic/backend/s3/s3_test.go b/src/restic/backend/s3/s3_test.go index ab4cc855..355352fa 100644 --- a/src/restic/backend/s3/s3_test.go +++ b/src/restic/backend/s3/s3_test.go @@ -6,7 +6,7 @@ import ( "os" "restic" - "github.com/pkg/errors" + "restic/errors" "restic/backend/s3" "restic/backend/test" diff --git a/src/restic/backend/sftp/config.go b/src/restic/backend/sftp/config.go index d8e20049..abd8b0c2 100644 --- a/src/restic/backend/sftp/config.go +++ b/src/restic/backend/sftp/config.go @@ -5,7 +5,7 @@ import ( "path" "strings" - "github.com/pkg/errors" + "restic/errors" ) // Config collects all information required to connect to an sftp server. diff --git a/src/restic/backend/sftp/sftp.go b/src/restic/backend/sftp/sftp.go index a4681142..b323eb1b 100644 --- a/src/restic/backend/sftp/sftp.go +++ b/src/restic/backend/sftp/sftp.go @@ -13,7 +13,7 @@ import ( "strings" "time" - "github.com/pkg/errors" + "restic/errors" "restic/backend" "restic/debug" diff --git a/src/restic/backend/sftp/sftp_backend_test.go b/src/restic/backend/sftp/sftp_backend_test.go index b7bcc259..567b2cf9 100644 --- a/src/restic/backend/sftp/sftp_backend_test.go +++ b/src/restic/backend/sftp/sftp_backend_test.go @@ -7,7 +7,7 @@ import ( "restic" "strings" - "github.com/pkg/errors" + "restic/errors" "restic/backend/sftp" "restic/backend/test" diff --git a/src/restic/backend/test/tests.go b/src/restic/backend/test/tests.go index 8134eafb..4171b0bd 100644 --- a/src/restic/backend/test/tests.go +++ b/src/restic/backend/test/tests.go @@ -11,7 +11,7 @@ import ( "sort" "testing" - "github.com/pkg/errors" + "restic/errors" "restic/backend" . "restic/test" diff --git a/src/restic/backend/test/tests_test.go b/src/restic/backend/test/tests_test.go index 92c08644..04e9936e 100644 --- a/src/restic/backend/test/tests_test.go +++ b/src/restic/backend/test/tests_test.go @@ -3,7 +3,7 @@ package test_test import ( "restic" - "github.com/pkg/errors" + "restic/errors" "restic/backend/mem" "restic/backend/test" diff --git a/src/restic/backend/utils.go b/src/restic/backend/utils.go index f060b6fc..82a89951 100644 --- a/src/restic/backend/utils.go +++ b/src/restic/backend/utils.go @@ -4,7 +4,7 @@ import ( "io" "restic" - "github.com/pkg/errors" + "restic/errors" ) // LoadAll reads all data stored in the backend for the handle. The buffer buf diff --git a/src/restic/backend_find.go b/src/restic/backend_find.go index d788e679..193fd165 100644 --- a/src/restic/backend_find.go +++ b/src/restic/backend_find.go @@ -1,6 +1,6 @@ package restic -import "github.com/pkg/errors" +import "restic/errors" // ErrNoIDPrefixFound is returned by Find() when no ID for the given prefix // could be found. diff --git a/src/restic/blob.go b/src/restic/blob.go index 56e478ad..6074b59b 100644 --- a/src/restic/blob.go +++ b/src/restic/blob.go @@ -3,7 +3,7 @@ package restic import ( "fmt" - "github.com/pkg/errors" + "restic/errors" ) // Blob is one part of a file or a tree. diff --git a/src/restic/checker/checker.go b/src/restic/checker/checker.go index 9d673a94..88a8eec8 100644 --- a/src/restic/checker/checker.go +++ b/src/restic/checker/checker.go @@ -5,7 +5,7 @@ import ( "fmt" "sync" - "github.com/pkg/errors" + "restic/errors" "restic" "restic/backend" diff --git a/src/restic/config.go b/src/restic/config.go index 5d169929..0afb5426 100644 --- a/src/restic/config.go +++ b/src/restic/config.go @@ -3,7 +3,7 @@ package restic import ( "testing" - "github.com/pkg/errors" + "restic/errors" "restic/debug" diff --git a/src/restic/crypto/crypto.go b/src/restic/crypto/crypto.go index 33b9dfda..2ebf5d31 100644 --- a/src/restic/crypto/crypto.go +++ b/src/restic/crypto/crypto.go @@ -7,7 +7,7 @@ import ( "encoding/json" "fmt" - "github.com/pkg/errors" + "restic/errors" "golang.org/x/crypto/poly1305" ) diff --git a/src/restic/crypto/kdf.go b/src/restic/crypto/kdf.go index ea8be37b..ccde35ac 100644 --- a/src/restic/crypto/kdf.go +++ b/src/restic/crypto/kdf.go @@ -5,8 +5,8 @@ import ( "time" sscrypt "github.com/elithrar/simple-scrypt" - "github.com/pkg/errors" "golang.org/x/crypto/scrypt" + "restic/errors" ) const saltLength = 64 diff --git a/src/restic/debug/debug.go b/src/restic/debug/debug.go index aeae376c..b1ab2b38 100644 --- a/src/restic/debug/debug.go +++ b/src/restic/debug/debug.go @@ -15,7 +15,7 @@ import ( "sync" "time" - "github.com/pkg/errors" + "restic/errors" ) type process struct { diff --git a/src/restic/errors/doc.go b/src/restic/errors/doc.go new file mode 100644 index 00000000..9f63cf95 --- /dev/null +++ b/src/restic/errors/doc.go @@ -0,0 +1,2 @@ +// Package errors provides custom error types used within restic. +package errors diff --git a/src/restic/errors.go b/src/restic/errors/fatal.go similarity index 98% rename from src/restic/errors.go rename to src/restic/errors/fatal.go index 1aa7e1fd..dce3a92b 100644 --- a/src/restic/errors.go +++ b/src/restic/errors/fatal.go @@ -1,4 +1,4 @@ -package restic +package errors import "fmt" diff --git a/src/restic/errors/wrap.go b/src/restic/errors/wrap.go new file mode 100644 index 00000000..65b48de8 --- /dev/null +++ b/src/restic/errors/wrap.go @@ -0,0 +1,23 @@ +package errors + +import "github.com/pkg/errors" + +// Cause returns the cause of an error. +func Cause(err error) error { + return errors.Cause(err) +} + +// New creates a new error based on message. +func New(message string) error { + return errors.New(message) +} + +// Errorf creates an error based on a format string and values. +func Errorf(format string, args ...interface{}) error { + return errors.Errorf(format, args...) +} + +// Wrap wraps an error retrieved from outside of restic. +func Wrap(err error, message string) error { + return errors.Wrap(err, message) +} diff --git a/src/restic/file.go b/src/restic/file.go index 166546f5..bfe44ad4 100644 --- a/src/restic/file.go +++ b/src/restic/file.go @@ -3,7 +3,7 @@ package restic import ( "fmt" - "github.com/pkg/errors" + "restic/errors" ) // FileType is the type of a file in the backend. diff --git a/src/restic/filter/filter.go b/src/restic/filter/filter.go index 48ce01fb..bb483d31 100644 --- a/src/restic/filter/filter.go +++ b/src/restic/filter/filter.go @@ -4,7 +4,7 @@ import ( "path/filepath" "strings" - "github.com/pkg/errors" + "restic/errors" ) // ErrBadString is returned when Match is called with the empty string as the diff --git a/src/restic/fs/file_linux.go b/src/restic/fs/file_linux.go index e3cdf960..f02c6470 100644 --- a/src/restic/fs/file_linux.go +++ b/src/restic/fs/file_linux.go @@ -6,7 +6,7 @@ import ( "os" "syscall" - "github.com/pkg/errors" + "restic/errors" "golang.org/x/sys/unix" ) diff --git a/src/restic/fuse/file.go b/src/restic/fuse/file.go index 83a17347..d5949ee8 100644 --- a/src/restic/fuse/file.go +++ b/src/restic/fuse/file.go @@ -6,7 +6,7 @@ package fuse import ( "sync" - "github.com/pkg/errors" + "restic/errors" "restic" "restic/debug" diff --git a/src/restic/fuse/file_test.go b/src/restic/fuse/file_test.go index bd7bfdca..58e6b33b 100644 --- a/src/restic/fuse/file_test.go +++ b/src/restic/fuse/file_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/pkg/errors" + "restic/errors" "bazil.org/fuse" diff --git a/src/restic/id.go b/src/restic/id.go index 5a1f4ab6..6d1f55de 100644 --- a/src/restic/id.go +++ b/src/restic/id.go @@ -8,7 +8,7 @@ import ( "encoding/json" "io" - "github.com/pkg/errors" + "restic/errors" ) // Hash returns the ID for data. diff --git a/src/restic/index/index.go b/src/restic/index/index.go index e2f7f831..9027e3fd 100644 --- a/src/restic/index/index.go +++ b/src/restic/index/index.go @@ -9,7 +9,7 @@ import ( "restic/list" "restic/worker" - "github.com/pkg/errors" + "restic/errors" ) // Pack contains information about the contents of a pack. diff --git a/src/restic/lock.go b/src/restic/lock.go index 2cb0a113..f32df4f7 100644 --- a/src/restic/lock.go +++ b/src/restic/lock.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/pkg/errors" + "restic/errors" "restic/debug" ) diff --git a/src/restic/lock_unix.go b/src/restic/lock_unix.go index 6b481ed2..d1b7fb0a 100644 --- a/src/restic/lock_unix.go +++ b/src/restic/lock_unix.go @@ -8,7 +8,7 @@ import ( "strconv" "syscall" - "github.com/pkg/errors" + "restic/errors" "restic/debug" ) diff --git a/src/restic/mock/backend.go b/src/restic/mock/backend.go index 717f38bf..5aadc849 100644 --- a/src/restic/mock/backend.go +++ b/src/restic/mock/backend.go @@ -3,7 +3,7 @@ package mock import ( "restic" - "github.com/pkg/errors" + "restic/errors" ) // Backend implements a mock backend. diff --git a/src/restic/node.go b/src/restic/node.go index 842517d4..427ed630 100644 --- a/src/restic/node.go +++ b/src/restic/node.go @@ -10,7 +10,7 @@ import ( "syscall" "time" - "github.com/pkg/errors" + "restic/errors" "runtime" diff --git a/src/restic/node_linux.go b/src/restic/node_linux.go index 57a5e5c4..7ebad89f 100644 --- a/src/restic/node_linux.go +++ b/src/restic/node_linux.go @@ -6,7 +6,7 @@ import ( "golang.org/x/sys/unix" - "github.com/pkg/errors" + "restic/errors" "restic/fs" ) diff --git a/src/restic/node_windows.go b/src/restic/node_windows.go index 08a7f86a..050de8f2 100644 --- a/src/restic/node_windows.go +++ b/src/restic/node_windows.go @@ -3,7 +3,7 @@ package restic import ( "syscall" - "github.com/pkg/errors" + "restic/errors" ) // mknod() creates a filesystem node (file, device diff --git a/src/restic/pack/pack.go b/src/restic/pack/pack.go index a1e62d54..40d10839 100644 --- a/src/restic/pack/pack.go +++ b/src/restic/pack/pack.go @@ -8,7 +8,7 @@ import ( "restic" "sync" - "github.com/pkg/errors" + "restic/errors" "restic/crypto" ) diff --git a/src/restic/pipe/pipe.go b/src/restic/pipe/pipe.go index 48a83a36..1ed9b616 100644 --- a/src/restic/pipe/pipe.go +++ b/src/restic/pipe/pipe.go @@ -6,7 +6,7 @@ import ( "path/filepath" "sort" - "github.com/pkg/errors" + "restic/errors" "restic/debug" "restic/fs" diff --git a/src/restic/rand_reader.go b/src/restic/rand_reader.go index cfe50222..205fd6ab 100644 --- a/src/restic/rand_reader.go +++ b/src/restic/rand_reader.go @@ -4,7 +4,7 @@ import ( "io" "math/rand" - "github.com/pkg/errors" + "restic/errors" ) // RandReader allows reading from a rand.Rand. diff --git a/src/restic/repository/index.go b/src/restic/repository/index.go index f543a25e..02937406 100644 --- a/src/restic/repository/index.go +++ b/src/restic/repository/index.go @@ -8,7 +8,7 @@ import ( "sync" "time" - "github.com/pkg/errors" + "restic/errors" "restic/crypto" "restic/debug" diff --git a/src/restic/repository/key.go b/src/restic/repository/key.go index 7b03ae10..b874dc64 100644 --- a/src/restic/repository/key.go +++ b/src/restic/repository/key.go @@ -8,7 +8,7 @@ import ( "restic" "time" - "github.com/pkg/errors" + "restic/errors" "restic/backend" "restic/crypto" diff --git a/src/restic/repository/master_index.go b/src/restic/repository/master_index.go index f82121fb..a3489e53 100644 --- a/src/restic/repository/master_index.go +++ b/src/restic/repository/master_index.go @@ -4,7 +4,7 @@ import ( "restic" "sync" - "github.com/pkg/errors" + "restic/errors" "restic/debug" ) diff --git a/src/restic/repository/packer_manager.go b/src/restic/repository/packer_manager.go index ea08a114..85c5b186 100644 --- a/src/restic/repository/packer_manager.go +++ b/src/restic/repository/packer_manager.go @@ -7,7 +7,7 @@ import ( "restic" "sync" - "github.com/pkg/errors" + "restic/errors" "restic/crypto" "restic/debug" diff --git a/src/restic/repository/parallel_test.go b/src/restic/repository/parallel_test.go index 30b0238b..cfa384a0 100644 --- a/src/restic/repository/parallel_test.go +++ b/src/restic/repository/parallel_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/pkg/errors" + "restic/errors" "restic/repository" . "restic/test" diff --git a/src/restic/repository/repack.go b/src/restic/repository/repack.go index 95e0eae0..274f2d32 100644 --- a/src/restic/repository/repack.go +++ b/src/restic/repository/repack.go @@ -8,7 +8,7 @@ import ( "restic/debug" "restic/pack" - "github.com/pkg/errors" + "restic/errors" ) // Repack takes a list of packs together with a list of blobs contained in diff --git a/src/restic/repository/repository.go b/src/restic/repository/repository.go index bc36e050..a400b85e 100644 --- a/src/restic/repository/repository.go +++ b/src/restic/repository/repository.go @@ -8,7 +8,7 @@ import ( "os" "restic" - "github.com/pkg/errors" + "restic/errors" "restic/backend" "restic/crypto" diff --git a/src/restic/restorer.go b/src/restic/restorer.go index 9784df8e..7ea7f012 100644 --- a/src/restic/restorer.go +++ b/src/restic/restorer.go @@ -4,7 +4,7 @@ import ( "os" "path/filepath" - "github.com/pkg/errors" + "restic/errors" "restic/debug" "restic/fs" diff --git a/src/restic/snapshot.go b/src/restic/snapshot.go index 4775cbd7..dc351e8e 100644 --- a/src/restic/snapshot.go +++ b/src/restic/snapshot.go @@ -7,7 +7,7 @@ import ( "path/filepath" "time" - "github.com/pkg/errors" + "restic/errors" ) // Snapshot is the state of a resource at one point in time. diff --git a/src/restic/testing.go b/src/restic/testing.go index 1be705bb..e4fe6ddb 100644 --- a/src/restic/testing.go +++ b/src/restic/testing.go @@ -8,8 +8,8 @@ import ( "testing" "time" - "github.com/pkg/errors" "github.com/restic/chunker" + "restic/errors" ) // fakeFile returns a reader which yields deterministic pseudo-random data. diff --git a/src/restic/tree.go b/src/restic/tree.go index 94e51b32..f27393fa 100644 --- a/src/restic/tree.go +++ b/src/restic/tree.go @@ -4,7 +4,7 @@ import ( "fmt" "sort" - "github.com/pkg/errors" + "restic/errors" "restic/debug" ) diff --git a/src/restic/worker/pool_test.go b/src/restic/worker/pool_test.go index 329ce9a8..9d6159b8 100644 --- a/src/restic/worker/pool_test.go +++ b/src/restic/worker/pool_test.go @@ -3,7 +3,7 @@ package worker_test import ( "testing" - "github.com/pkg/errors" + "restic/errors" "restic/worker" )