Better handle readdirent errors

This commit is contained in:
Matthew Penner 2020-09-24 21:48:59 -06:00
parent 897c4869de
commit 1a3ba9efca
2 changed files with 2 additions and 2 deletions

View File

@ -33,7 +33,7 @@ func TrackedError(err error) *RequestError {
// generated this server for the purposes of logging.
func TrackedServerError(err error, s *server.Server) *RequestError {
return &RequestError{
Err: errors.WithStack(err),
Err: err,
Uuid: uuid.Must(uuid.NewRandom()).String(),
Message: "",
server: s,

View File

@ -82,7 +82,7 @@ func getServerListDirectory(c *gin.Context) {
stats, err := s.Filesystem.ListDirectory(d)
if err != nil {
if err.Error() == "readdirent: not a directory" {
if e, ok := err.(*os.SyscallError); ok && e.Syscall == "readdirent" {
c.AbortWithStatusJSON(http.StatusNotFound, gin.H{
"error": "The requested directory does not exist.",
})