Update path validation error handling

This commit is contained in:
2024-11-28 21:18:30 +01:00
parent fbb8fa3a60
commit 91489ca633
4 changed files with 70 additions and 7 deletions

View File

@@ -0,0 +1,24 @@
// storage/errors.go
package storage
import (
"errors"
"fmt"
)
// PathValidationError represents a path validation error (e.g., path traversal attempt)
type PathValidationError struct {
Path string
Message string
}
func (e *PathValidationError) Error() string {
return fmt.Sprintf("%s: %s", e.Message, e.Path)
}
// IsPathValidationError checks if the error is a PathValidationError
func IsPathValidationError(err error) bool {
var pathErr *PathValidationError
return err != nil && errors.As(err, &pathErr)
}