relay_profiling/
error.rs

1use relay_filter::FilterStatKey;
2
3use thiserror::Error;
4
5#[derive(Debug, Error)]
6pub enum ProfileError {
7    #[error(transparent)]
8    InvalidJson(#[from] serde_path_to_error::Error<serde_json::Error>),
9    #[error("invalid base64 value")]
10    InvalidBase64Value,
11    #[error("invalid sampled profile")]
12    InvalidSampledProfile,
13    /// Error associated with an invalid [`ProfileType`](crate::ProfileType).
14    ///
15    /// Error is currently emitted when the inferred profile type from the payload
16    /// does not match the profile type inferred from the envelope item headers.
17    #[error("profile type invalid or mismatched")]
18    InvalidProfileType,
19    #[error("cannot serialize payload")]
20    CannotSerializePayload,
21    #[error("not enough samples")]
22    NotEnoughSamples,
23    #[error("platform not supported")]
24    PlatformNotSupported,
25    #[error("no transaction associated")]
26    NoTransactionAssociated,
27    #[error("invalid transaction metadata")]
28    InvalidTransactionMetadata,
29    #[error("missing profile metadata")]
30    MissingProfileMetadata,
31    #[error("malformed stacks")]
32    MalformedStacks,
33    #[error("malformed samples")]
34    MalformedSamples,
35    #[error("exceed size limit")]
36    ExceedSizeLimit,
37    #[error("too many profiles")]
38    TooManyProfiles,
39    #[error("duration is too long")]
40    DurationIsTooLong,
41    #[error("duration is zero")]
42    DurationIsZero,
43    #[error("filtered profile")]
44    Filtered(FilterStatKey),
45    #[error(transparent)]
46    InvalidBuildID(#[from] uuid::Error),
47}
48
49impl ProfileError {
50    pub fn path(self) -> String {
51        match self {
52            Self::InvalidJson(err) => err.path().to_string(),
53            _ => "".into(),
54        }
55    }
56}