Error handling improvements (#71)

* Remove `emperror.dev/errors`, remove all `errors#Wrap` and `errors#WithStack` calls
* Improve logging in `server/backup.go`
This commit is contained in:
Matthew Penner
2020-11-28 16:57:10 -07:00
committed by GitHub
parent 40c70673cd
commit de51fd1c51
55 changed files with 326 additions and 339 deletions

View File

@@ -4,9 +4,9 @@ import (
"bufio"
"bytes"
"context"
"emperror.dev/errors"
"encoding/json"
"github.com/docker/docker/api/types"
"github.com/pkg/errors"
"github.com/pterodactyl/wings/environment"
"strconv"
)
@@ -15,7 +15,7 @@ type dockerLogLine struct {
Log string `json:"log"`
}
var ErrNotAttached = errors.Sentinel("not attached to instance")
var ErrNotAttached = errors.New("not attached to instance")
func (e *Environment) setStream(s *types.HijackedResponse) {
e.mu.Lock()
@@ -42,7 +42,7 @@ func (e *Environment) SendCommand(c string) error {
_, err := e.stream.Conn.Write([]byte(c + "\n"))
return errors.WithStackIf(err)
return err
}
// Reads the log file for the server. This does not care if the server is running or not, it will
@@ -54,7 +54,7 @@ func (e *Environment) Readlog(lines int) ([]string, error) {
Tail: strconv.Itoa(lines),
})
if err != nil {
return nil, errors.WithStackIf(err)
return nil, err
}
defer r.Close()