sqlmap_rs/error.rs
1//! Error definitions for the sqlmapapi binding.
2//!
3//! Every error variant carries actionable context so callers can
4//! diagnose failures without raw subprocess inspection.
5
6use thiserror::Error;
7
8/// Core error type for sqlmap API interactions.
9///
10/// Covers the full lifecycle from daemon boot through scan completion.
11#[derive(Debug, Error)]
12#[non_exhaustive]
13pub enum SqlmapError {
14 /// Failed to launch or track the `sqlmapapi.py` subprocess.
15 #[error("API process error: {0}")]
16 ProcessError(#[from] std::io::Error),
17
18 /// The `sqlmapapi` binary or `python3` with sqlmap could not be found.
19 #[error("binary not found: {0} — ensure python3 and sqlmap are in PATH")]
20 BinaryNotFound(String),
21
22 /// HTTP request error when communicating with the REST API.
23 #[error("HTTP request failed: {0}")]
24 RequestError(#[from] reqwest::Error),
25
26 /// The API responded with `success: false`.
27 #[error("sqlmap API returned error: {0}")]
28 ApiError(String),
29
30 /// API responded with unexpected or malformed JSON structure.
31 #[error("malformed JSON response structure")]
32 MalformedResponse,
33
34 /// Polling timeout while waiting for task completion.
35 #[error("task execution timed out after {0} seconds")]
36 Timeout(u64),
37
38 /// The provided task ID was unrecognized by the server.
39 #[error("invalid task ID: {0}")]
40 InvalidTask(String),
41
42 /// The daemon failed to bind to the requested port.
43 #[error("port {port} is already in use — try a different port or use port 0 for auto-assignment")]
44 PortConflict {
45 /// The port that was requested.
46 port: u16,
47 },
48}