stylus_trace_core/utils/
error.rs1use thiserror::Error;
7
8#[derive(Error, Debug)]
10pub enum RpcError {
11 #[error("HTTP request failed: {0}")]
12 RequestFailed(#[from] reqwest::Error),
13
14 #[error("Invalid RPC response: {0}")]
15 InvalidResponse(String),
16
17 #[error("Transaction not found: {0}")]
18 TransactionNotFound(String),
19
20 #[error("Tracer not supported by this RPC endpoint")]
21 TracerNotSupported,
22}
23
24#[derive(Error, Debug)]
26pub enum ParseError {
27 #[error("JSON deserialization failed: {0}")]
28 JsonError(#[from] serde_json::Error),
29
30 #[error("Invalid trace format: {0}")]
31 InvalidFormat(String),
32 }
40
41#[derive(Error, Debug)]
43pub enum FlamegraphError {
44 #[error("Empty stack data")]
49 EmptyStacks,
50
51 #[error("IO error: {0}")]
52 IoError(#[from] std::io::Error),
53}
54
55#[derive(Error, Debug)]
57pub enum OutputError {
58 #[error("Failed to write file: {0}")]
59 WriteFailed(#[from] std::io::Error),
60
61 #[error("Failed to serialize JSON: {0}")]
62 SerializationFailed(#[from] serde_json::Error),
63
64 #[error("Invalid output path: {0}")]
65 InvalidPath(String),
66}
67
68#[derive(Error, Debug)]
70pub enum DiffError {
71 #[error("Incompatible schema versions: baseline={0}, target={1}")]
72 IncompatibleVersions(String, String),
73
74 #[error("Failed to read profile: {0}")]
75 ReadFailed(#[from] OutputError),
76
77 #[error("Invalid threshold configuration: {0}")]
78 InvalidThresholds(String),
79
80 #[error("Threshold TOML parse error: {0}")]
81 ThresholdParseFailed(#[from] toml::de::Error),
82
83 #[error("IO error: {0}")]
84 IoError(#[from] std::io::Error),
85}