diff --git a/web/err.go b/web/err.go index b87f7f74..72627624 100644 --- a/web/err.go +++ b/web/err.go @@ -44,19 +44,24 @@ func errors(val error, c *fibre.Context) { case *sql.ParseError: code, info = 400, e.Error() case *fibre.HTTPError: - code = e.Code() + code, info = e.Code(), e.Error() } if _, ok := errs[code]; !ok { code = 500 } - c.Send(code, &err{ - errs[code].Code, - errs[code].Details, - errs[code].Description, - info, - }) + switch c.Type() { + case "text/plain": + c.Send(code, info) + default: + c.Send(code, &err{ + errs[code].Code, + errs[code].Details, + errs[code].Description, + info, + }) + } } diff --git a/web/routes.go b/web/routes.go index d025c739..dc3a7003 100644 --- a/web/routes.go +++ b/web/routes.go @@ -24,7 +24,6 @@ import ( "github.com/abcum/surreal/sql" "github.com/abcum/surreal/util/build" "github.com/abcum/surreal/util/show" - "github.com/gorilla/websocket" ) func limit(c *fibre.Context, i int64) int64 { @@ -175,9 +174,6 @@ func routes(s *fibre.Fibre) { for { _, msg, err := c.Socket().Read() if err != nil { - if websocket.IsCloseError(err, 1000, 1001, 1005) { - return nil - } return err } if res, err := db.Execute(c, msg, nil); err != nil { @@ -186,7 +182,6 @@ func routes(s *fibre.Fibre) { c.Socket().SendJSON(res) } } - return nil }) // --------------------------------------------------