Correct some error handling, use package that provides useful stack traces

This commit is contained in:
Dane Everitt 2019-11-16 17:01:38 -08:00
parent 56be65888c
commit cae0090763
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
7 changed files with 24 additions and 9 deletions

View File

@ -2,9 +2,9 @@ package api
import (
"bytes"
"errors"
"fmt"
"github.com/buger/jsonparser"
"github.com/pkg/errors"
"github.com/pterodactyl/wings/config"
"go.uber.org/zap"
"io/ioutil"

View File

@ -2,9 +2,9 @@ package api
import (
"encoding/json"
"errors"
"fmt"
"github.com/buger/jsonparser"
"github.com/pkg/errors"
"go.uber.org/zap"
)

21
http.go
View File

@ -158,19 +158,34 @@ func (rt *Router) routeServerPower(w http.ResponseWriter, r *http.Request, ps ht
switch a {
case "start":
if err := s.Environment.Start(); err != nil {
zap.S().Error(err, zap.String("server", s.Uuid), zap.String("action", "start"))
zap.S().Errorw(
"encountered unexpected error starting server process",
zap.Error(err),
zap.String("server", s.Uuid),
zap.String("action", "start"),
)
}
break
case "stop":
if err := s.Environment.Stop(); err != nil {
zap.S().Error(err, zap.String("server", s.Uuid), zap.String("action", "stop"))
zap.S().Errorw(
"encountered unexpected error stopping server process",
zap.Error(err),
zap.String("server", s.Uuid),
zap.String("action", "stop"),
)
}
break
case "restart":
break
case "kill":
if err := s.Environment.Terminate(os.Kill); err != nil {
zap.S().Error(err, zap.String("server", s.Uuid), zap.String("action", "kill"))
zap.S().Errorw(
"encountered unexpected error killing server process",
zap.Error(err),
zap.String("server", s.Uuid),
zap.String("action", "kill"),
)
}
}
}(action.Action, s)

View File

@ -2,9 +2,9 @@ package installer
import (
"encoding/json"
"errors"
"github.com/asaskevich/govalidator"
"github.com/buger/jsonparser"
"github.com/pkg/errors"
"github.com/pterodactyl/wings/config"
"github.com/pterodactyl/wings/server"
"go.uber.org/zap"

View File

@ -4,9 +4,9 @@ import (
"bufio"
"bytes"
"encoding/json"
"errors"
"fmt"
"github.com/gabriel-vasile/mimetype"
"github.com/pkg/errors"
"github.com/pterodactyl/wings/config"
"go.uber.org/zap"
"io"

View File

@ -1,9 +1,9 @@
package server
import (
"errors"
"fmt"
"github.com/patrickmn/go-cache"
"github.com/pkg/errors"
"github.com/pterodactyl/wings/api"
"github.com/pterodactyl/wings/config"
"github.com/remeh/sizedwaitgroup"

View File

@ -2,12 +2,12 @@ package main
import (
"encoding/json"
"errors"
"fmt"
"github.com/gbrlsnchs/jwt/v3"
"github.com/google/uuid"
"github.com/gorilla/websocket"
"github.com/julienschmidt/httprouter"
"github.com/pkg/errors"
"github.com/pterodactyl/wings/config"
"github.com/pterodactyl/wings/server"
"go.uber.org/zap"