mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-06 07:54:22 +00:00
Update path validation error handling
This commit is contained in:
24
server/internal/storage/errors.go
Normal file
24
server/internal/storage/errors.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user