#[non_exhaustive]pub enum FileError {
Show 16 variants
TooLarge {
size: usize,
max: usize,
},
InvalidType {
got: String,
allowed: Vec<String>,
},
MimeMismatch {
declared: String,
detected: String,
},
Storage {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
Processing {
message: String,
},
NotFound {
id: String,
},
VirusDetected {
details: String,
},
QuotaExceeded,
PermissionDenied {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
IoError {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
InvalidKey {
message: String,
},
NotImplemented {
message: String,
},
Unsupported {
message: String,
},
SizeLimitExceeded {
message: String,
limit: Option<u64>,
actual: Option<u64>,
},
MimeTypeNotAllowed {
message: String,
mime: Option<String>,
},
Backend {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
}Expand description
Errors that occur during file upload, validation, storage, or retrieval.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
TooLarge
The uploaded file exceeds the configured maximum size.
Fields
InvalidType
The file’s extension or declared MIME type is not on the allow-list.
Fields
MimeMismatch
The file’s declared MIME type does not match its detected MIME type.
This can indicate a spoofed Content-Type header.
Fields
Storage
An error occurred while writing to or reading from the backing storage system (e.g. local disk, object store).
Fields
Processing
An error occurred while processing the file contents (e.g. image resizing, format conversion).
NotFound
The requested file does not exist in the storage backend.
VirusDetected
A virus or malware scanner flagged the uploaded file.
QuotaExceeded
The user or tenant has exhausted their file storage quota.
PermissionDenied
The backend refused the request because the caller lacks permission (e.g. an object-store bucket policy denied the operation, IAM credentials are missing the required action, the SAS token is expired).
Distinct from a missing-credentials authentication failure — those
surface as crate::FraiseQLError::Authentication.
Fields
IoError
A low-level I/O failure occurred while talking to the storage backend (filesystem read/write error, socket failure, JSON-parse failure on a backend response).
Fields
InvalidKey
The caller supplied a key that fails validation (empty, path-traversal
segment, leading / or \). User-fixable; HTTP 400.
NotImplemented
The requested operation is not implemented for this backend
(e.g. list on GCS, presigned URLs without V4 signing on Azure).
The capability exists in the API surface but is unimplemented.
Unsupported
The requested operation is not supported by this backend at all (e.g. presigned URLs for the local filesystem, presign-PUT for the non-S3 enum variants).
SizeLimitExceeded
The upload exceeds the configured per-bucket size limit.
Distinct from Self::TooLarge, which is set by client-side
validation against max_object_bytes. This variant is raised by the
service layer when the limit is enforced post-upload (e.g. for streaming
uploads where the total size is only known once the body has been
read).
Fields
MimeTypeNotAllowed
The uploaded content type is not on the per-bucket allow-list.
Distinct from Self::InvalidType, which is raised at extension /
MIME-sniffing time. This variant is raised by the service layer
against the configured allowed_mime_types list.
Fields
Backend
A generic backend / infrastructure failure with no more-specific classification.
Used for object-store authentication setup failures (missing env vars,
invalid credentials JSON), backend HTTP-request failures, configuration
errors (s3 backend without bucket config), and database failures in
the storage metadata layer. Returns HTTP 500.
Implementations§
Source§impl FileError
impl FileError
Sourcepub const fn error_code(&self) -> &'static str
pub const fn error_code(&self) -> &'static str
Returns a short, stable error code string suitable for API responses and structured logging.
Sourcepub const fn status_code(&self) -> u16
pub const fn status_code(&self) -> u16
Returns the HTTP status code this variant maps to when surfaced
through crate::FraiseQLError::File.
User-fixable validation failures map to 4xx; backend / infrastructure
failures map to 5xx. The split here preserves what
fraiseql-storage/src/routes/mod.rs::storage_error_response previously
hard-coded via the code: Option<String> discriminator on the
(now-deprecated) FraiseQLError::Storage variant:
NotFound→ 404 — backend reports object missingPermissionDenied→ 403 — backend refuses the operationInvalidKey→ 400 — caller supplied a malformed keyIoError,Backend,NotImplemented,Unsupported,SizeLimitExceeded,MimeTypeNotAllowed→ 500 — preserves the legacy behavior ofFraiseQLError::Storage(which routed everycodeexceptnot_found/permission_deniedto 500 viastorage_error_response)- All other (pre-existing) variants —
TooLarge,InvalidType,MimeMismatch,VirusDetected,QuotaExceeded,Storage,Processing— fall back to theFraiseQLError::File-level 400 via the wildcard arm so that pre-F050 callers see unchanged HTTP responses.
Trait Implementations§
Source§impl Error for FileError
impl Error for FileError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()