wordpress_vulnerable_scanner/
error.rs

1//! Error types for WordPress vulnerability scanner
2
3use std::io;
4use thiserror::Error;
5
6/// Result type alias using our Error
7pub type Result<T> = std::result::Result<T, Error>;
8
9/// Errors that can occur during vulnerability scanning
10#[derive(Debug, Error)]
11pub enum Error {
12    /// Invalid URL provided
13    #[error("invalid URL: {0}")]
14    InvalidUrl(String),
15
16    /// HTTP client creation failed
17    #[error("failed to create HTTP client: {0}")]
18    HttpClient(String),
19
20    /// HTTP request failed
21    #[error("HTTP request failed: {0}")]
22    HttpRequest(String),
23
24    /// HTTP response had non-success status
25    #[error("HTTP error: status {0}")]
26    HttpStatus(u16),
27
28    /// Failed to parse API response
29    #[error("failed to parse API response: {0}")]
30    ApiParse(String),
31
32    /// Vulnerability API returned an error
33    #[error("vulnerability API error: {0}")]
34    VulnApi(String),
35
36    /// No input provided (no URL, plugins, themes, or manifest)
37    #[error("no input provided: specify a URL, --plugins, --themes, --core, or --manifest")]
38    NoInput,
39
40    /// Failed to read manifest file
41    #[error("failed to read manifest file: {0}")]
42    ManifestRead(String),
43
44    /// Failed to parse manifest file
45    #[error("failed to parse manifest file: {0}")]
46    ManifestParse(String),
47
48    /// Invalid plugin format (expected slug:version)
49    #[error("invalid plugin format '{0}': expected 'slug:version' or 'slug'")]
50    InvalidPluginFormat(String),
51
52    /// Invalid theme format (expected slug:version)
53    #[error("invalid theme format '{0}': expected 'slug:version' or 'slug'")]
54    InvalidThemeFormat(String),
55
56    /// Output failed
57    #[error("output failed: {0}")]
58    OutputFailed(#[from] io::Error),
59
60    /// JSON serialization failed
61    #[error("JSON serialization failed: {0}")]
62    JsonSerialize(#[from] serde_json::Error),
63
64    /// Invalid output format
65    #[error("invalid output format: {0}")]
66    InvalidOutputFormat(String),
67
68    /// Invalid severity level
69    #[error("invalid severity level: {0}")]
70    InvalidSeverity(String),
71}