func (e *RequestError) Error() string {
	return fmt.Sprintf("%v (uuid: %s)", e.err, e.uuid)
}
Format the error to a string and include the UUID.
package router
import (
	"fmt"
	"net/http"
	"os"
	"strings"
	"emperror.dev/errors"
	"github.com/apex/log"
	"github.com/gin-gonic/gin"
	"github.com/google/uuid"
	"github.com/pterodactyl/wings/server"
	"github.com/pterodactyl/wings/server/filesystem"
)
type RequestError struct {
	err     error
	uuid    string
	message string
	server  *server.Server
}
func WithError(c *gin.Context, err error) error {
	return c.Error(errors.WithStackDepthIf(err, 1))
}
func NewTrackedError(err error) *RequestError {
	return &RequestError{
		err:  err,
		uuid: uuid.Must(uuid.NewRandom()).String(),
	}
}
func NewServerError(err error, s *server.Server) *RequestError {
	return &RequestError{
		err:    err,
		uuid:   uuid.Must(uuid.NewRandom()).String(),
		server: s,
	}
}
func (e *RequestError) logger() *log.Entry {
	if e.server != nil {
		return e.server.Log().WithField("error_id", e.uuid).WithField("error", e.err)
	}
	return log.WithField("error_id", e.uuid).WithField("error", e.err)
}
func (e *RequestError) SetMessage(msg string) *RequestError {
	e.message = msg
	return e
}
func (e *RequestError) AbortWithStatus(status int, c *gin.Context) {
	if c.Writer.Status() != 200 {
		status = c.Writer.Status()
	}
	if errors.Is(e.err, os.ErrNotExist) {
		c.AbortWithStatusJSON(http.StatusNotFound, gin.H{
			"error": "The requested resource was not found on the system.",
		})
		return
	}
	if strings.HasPrefix(e.err.Error(), "invalid URL escape") {
		c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{
			"error": "Some of the data provided in the request appears to be escaped improperly.",
		})
		return
	}
	if st, msg := e.getAsFilesystemError(); st != 0 {
		c.AbortWithStatusJSON(st, gin.H{"error": msg})
		return
	}
	if status >= 500 {
		e.logger().Error("unexpected error while handling HTTP request")
	} else {
		e.logger().Debug("non-server error encountered while handling HTTP request")
	}
	if e.message == "" {
		e.message = "An unexpected error was encountered while processing this request."
	}
	c.AbortWithStatusJSON(status, gin.H{"error": e.message, "error_id": e.uuid})
}
func (e *RequestError) Abort(c *gin.Context) {
	e.AbortWithStatus(http.StatusInternalServerError, c)
}
func (e *RequestError) getAsFilesystemError() (int, string) {
	if filesystem.IsErrorCode(e.err, filesystem.ErrCodeDenylistFile) || strings.Contains(e.err.Error(), "filesystem: file access prohibited") {
		return http.StatusForbidden, "This file cannot be modified: present in egg denylist."
	}
	if filesystem.IsErrorCode(e.err, filesystem.ErrCodePathResolution) || strings.Contains(e.err.Error(), "resolves to a location outside the server root") {
		return http.StatusNotFound, "The requested resource was not found on the system."
	}
	if filesystem.IsErrorCode(e.err, filesystem.ErrCodeIsDirectory) || strings.Contains(e.err.Error(), "filesystem: is a directory") {
		return http.StatusBadRequest, "Cannot perform that action: file is a directory."
	}
	if filesystem.IsErrorCode(e.err, filesystem.ErrCodeDiskSpace) || strings.Contains(e.err.Error(), "filesystem: not enough disk space") {
		return http.StatusBadRequest, "Cannot perform that action: not enough disk space available."
	}
	if strings.HasSuffix(e.err.Error(), "file name too long") {
		return http.StatusBadRequest, "Cannot perform that action: file name is too long."
	}
	if e, ok := e.err.(*os.SyscallError); ok && e.Syscall == "readdirent" {
		return http.StatusNotFound, "The requested directory does not exist."
	}
	return 0, ""
}
func (e *RequestError) AbortFilesystemError(c *gin.Context) {
	e.Abort(c)
}