pub enum MultipartError {
InvalidBoundary,
FieldTooLarge {
field_name: String,
max_size: usize,
},
TooManyFields {
max_fields: usize,
},
RequestTooLarge {
max_size: usize,
},
InvalidField(String),
Io(Error),
InvalidUtf8(Utf8Error),
Parse(String),
}Expand description
Errors that can occur during multipart form data parsing.
This enum covers all possible error conditions that may arise when processing multipart/form-data requests, from validation issues to resource limit violations.
§Error Categories
§Validation Errors
InvalidBoundary: The boundary parameter is malformedInvalidField: A field has invalid format or headersInvalidUtf8: Text field contains invalid UTF-8 sequences
§Size Limit Errors
FieldTooLarge: An individual field exceeds the configured size limitTooManyFields: The request contains more fields than allowedRequestTooLarge: The entire request exceeds the size limit
§System Errors
Io: File system or network I/O errorsParse: Low-level parsing errors from the multipart library
§Examples
use ignitia::multipart::MultipartError;
match error {
MultipartError::FieldTooLarge { field_name, max_size } => {
println!("Field '{}' is too large (max: {} bytes)", field_name, max_size);
}
MultipartError::TooManyFields { max_fields } => {
println!("Too many fields (max: {})", max_fields);
}
MultipartError::InvalidBoundary => {
println!("Invalid multipart boundary");
}
_ => {
println!("Other multipart error: {}", error);
}
}Variants§
InvalidBoundary
The multipart boundary parameter is invalid or malformed.
This occurs when the Content-Type header contains an invalid boundary parameter, or when the boundary is not properly formatted according to RFC 2046 specifications.
§HTTP Status
This error maps to HTTP 400 Bad Request.
FieldTooLarge
A field exceeds the maximum allowed size.
This error is thrown when an individual field’s content exceeds
the max_field_size limit configured in MultipartConfig.
§Fields
field_name: The name of the field that exceeded the limitmax_size: The maximum allowed size in bytes
§HTTP Status
This error maps to HTTP 413 Payload Too Large.
§Examples
use ignitia::multipart::MultipartError;
let error = MultipartError::FieldTooLarge {
field_name: "upload_file".to_string(),
max_size: 1024 * 1024, // 1MB
};Fields
TooManyFields
The request contains too many fields.
This error occurs when the number of fields in the multipart request
exceeds the max_fields limit configured in MultipartConfig.
§Fields
max_fields: The maximum number of fields allowed
§HTTP Status
This error maps to HTTP 413 Payload Too Large.
RequestTooLarge
The entire request size exceeds the configured limit.
This error is thrown when the total size of all fields combined
exceeds the max_request_size limit configured in MultipartConfig.
§Fields
max_size: The maximum allowed request size in bytes
§HTTP Status
This error maps to HTTP 413 Payload Too Large.
InvalidField(String)
A field has invalid format or headers.
This error occurs when a multipart field is malformed, has missing required headers, or contains invalid header values.
§HTTP Status
This error maps to HTTP 400 Bad Request.
Io(Error)
An I/O error occurred during parsing.
This wraps standard I/O errors that may occur when reading from the request stream, writing temporary files, or performing other file system operations.
§HTTP Status
This error maps to HTTP 400 Bad Request (though it could indicate a server-side issue in some cases).
InvalidUtf8(Utf8Error)
A text field contains invalid UTF-8 sequences.
This error occurs when attempting to parse a field as text, but the field content is not valid UTF-8.
§HTTP Status
This error maps to HTTP 400 Bad Request.
Parse(String)
A low-level parsing error occurred.
This wraps errors from the underlying multipart parsing library, typically indicating malformed multipart data that doesn’t conform to RFC standards.
§HTTP Status
This error maps to HTTP 400 Bad Request.
Trait Implementations§
Source§impl CustomError for MultipartError
impl CustomError for MultipartError
Source§fn status_code(&self) -> StatusCode
fn status_code(&self) -> StatusCode
Returns the appropriate HTTP status code for this error.
Size-related errors return 413 Payload Too Large, while validation and parsing errors return 400 Bad Request.
Source§fn error_type(&self) -> &'static str
fn error_type(&self) -> &'static str
Returns a string identifier for the error type.
This is used in structured error responses to help clients programmatically identify and handle different error types.
Source§impl Debug for MultipartError
impl Debug for MultipartError
Source§impl Display for MultipartError
impl Display for MultipartError
Source§impl Error for MultipartError
impl Error for MultipartError
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
Source§impl From<Error> for MultipartError
impl From<Error> for MultipartError
Source§impl From<MultipartError> for Error
impl From<MultipartError> for Error
Source§fn from(err: MultipartError) -> Self
fn from(err: MultipartError) -> Self
Converts a MultipartError into the framework’s main Error type.
This allows multipart errors to be seamlessly integrated with Ignitia’s error handling and response generation system.
Source§impl From<MultipartError> for MultipartRejection
impl From<MultipartError> for MultipartRejection
Source§fn from(err: MultipartError) -> Self
fn from(err: MultipartError) -> Self
Converts a MultipartError into a MultipartRejection.