Convert all filesystem error types into the same Error struct

This commit is contained in:
Dane Everitt
2020-12-15 20:51:13 -08:00
parent 9ae75a399b
commit 3a26a5d39d
11 changed files with 104 additions and 75 deletions

View File

@@ -99,8 +99,8 @@ func (e *RequestError) Abort(c *gin.Context) {
// Handle specific filesystem errors for a server.
func (e *RequestError) AbortFilesystemError(c *gin.Context) {
if errors.Is(e.Err, os.ErrNotExist) || filesystem.IsBadPathResolutionError(e.Err) {
if filesystem.IsBadPathResolutionError(e.Err) {
if errors.Is(e.Err, os.ErrNotExist) || filesystem.IsErrorCode(e.Err, filesystem.ErrCodePathResolution) {
if filesystem.IsErrorCode(e.Err, filesystem.ErrCodePathResolution) {
e.logger().Warn(e.Err.Error())
}
@@ -108,7 +108,7 @@ func (e *RequestError) AbortFilesystemError(c *gin.Context) {
return
}
if errors.Is(e.Err, filesystem.ErrNotEnoughDiskSpace) {
if filesystem.IsErrorCode(e.Err, filesystem.ErrCodeDiskSpace) {
c.AbortWithStatusJSON(http.StatusConflict, gin.H{"error": "There is not enough disk space available to perform that action."})
return
}