summaryrefslogtreecommitdiffstats
path: root/pkg/commands/os.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2019-02-11 22:46:27 +1100
committerJesse Duffield <jessedduffield@gmail.com>2019-02-11 22:46:27 +1100
commit6430ab6ac9297142416ff4bbf6420161356742c6 (patch)
treecdcb83f01ad23a92dae7f4be69aaaa35a8c6a19a /pkg/commands/os.go
parent75ab8ec4d95b96fc9b8182154910609832265c3b (diff)
parente09f3905e962be254bffb9736f88799e61fa5fcf (diff)
Merge branch 'master' into feature/rebasing
Diffstat (limited to 'pkg/commands/os.go')
-rw-r--r--pkg/commands/os.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/pkg/commands/os.go b/pkg/commands/os.go
index 186887b5d..a1f936dc1 100644
--- a/pkg/commands/os.go
+++ b/pkg/commands/os.go
@@ -1,13 +1,14 @@
package commands
import (
- "errors"
"io/ioutil"
"os"
"os/exec"
"regexp"
"strings"
+ "github.com/go-errors/errors"
+
"github.com/jesseduffield/lazygit/pkg/config"
"github.com/jesseduffield/lazygit/pkg/utils"
"github.com/mgutz/str"
@@ -122,7 +123,7 @@ func sanitisedCommandOutput(output []byte, err error) (string, error) {
// errors like 'exit status 1' are not very useful so we'll create an error
// from the combined output
if outputString == "" {
- return "", err
+ return "", errors.Wrap(err, 0)
}
return outputString, errors.New(outputString)
}
@@ -201,12 +202,12 @@ func (c *OSCommand) Unquote(message string) string {
func (c *OSCommand) AppendLineToFile(filename, line string) error {
f, err := os.OpenFile(filename, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
if err != nil {
- return err
+ return errors.Wrap(err, 0)
}
defer f.Close()
_, err = f.WriteString("\n" + line)
- return err
+ return errors.Wrap(err, 0)
}
// CreateTempFile writes a string to a new temp file and returns the file's name
@@ -214,16 +215,16 @@ func (c *OSCommand) CreateTempFile(filename, content string) (string, error) {
tmpfile, err := ioutil.TempFile("", filename)
if err != nil {
c.Log.Error(err)
- return "", err
+ return "", errors.Wrap(err, 0)
}
if _, err := tmpfile.WriteString(content); err != nil {
c.Log.Error(err)
- return "", err
+ return "", errors.Wrap(err, 0)
}
if err := tmpfile.Close(); err != nil {
c.Log.Error(err)
- return "", err
+ return "", errors.Wrap(err, 0)
}
return tmpfile.Name(), nil
@@ -231,7 +232,8 @@ func (c *OSCommand) CreateTempFile(filename, content string) (string, error) {
// RemoveFile removes a file at the specified path
func (c *OSCommand) RemoveFile(filename string) error {
- return os.Remove(filename)
+ err := os.Remove(filename)
+ return errors.Wrap(err, 0)
}
// FileExists checks whether a file exists at the specified path