Different handling of errors on routes; push towards using middleware

This commit is contained in:
Dane Everitt
2020-12-15 21:53:34 -08:00
parent 057cdbd927
commit c0a641247b
6 changed files with 32 additions and 27 deletions

View File

@@ -57,14 +57,11 @@ func getServerFileContents(c *gin.Context) {
// Returns the contents of a directory for a server.
func getServerListDirectory(c *gin.Context) {
s := ExtractServer(c)
stats, err := s.Filesystem().ListDirectory(c.Query("directory"))
if err != nil {
NewServerError(err, s).AbortFilesystemError(c)
return
if stats, err := s.Filesystem().ListDirectory(c.Query("directory")); err != nil {
WithError(c, err)
} else {
c.JSON(http.StatusOK, stats)
}
c.JSON(http.StatusOK, stats)
}
type renameFile struct {