Skip to main content

serenade_form/
error.rs

1//! Form component errors.
2
3use serenade_security::SecurityError;
4
5/// Form bind / CSRF / parse failure.
6#[derive(Debug, thiserror::Error, Clone, PartialEq, Eq)]
7pub enum FormError {
8    /// Request body is not valid `application/x-www-form-urlencoded`.
9    #[error("invalid form body encoding")]
10    InvalidEncoding,
11    /// Multipart body is invalid or exceeds configured limits.
12    #[error("invalid multipart form body: {0}")]
13    Multipart(String),
14    /// Uploaded file rejected (size, MIME type, or I/O).
15    #[error("uploaded file rejected: {0}")]
16    Upload(String),
17    /// CSRF check failed.
18    #[error(transparent)]
19    Csrf(#[from] SecurityError),
20    /// Form was not submitted (wrong method or empty bind).
21    #[error("form not submitted")]
22    NotSubmitted,
23    /// View ↔ model transform failed.
24    #[error("form transform failed: {0}")]
25    Transform(String),
26    /// Flat key path conflicts (leaf vs map) while nesting form data.
27    #[error("nested form data conflict at {0}")]
28    NestedConflict(String),
29}