Skip to main content

suno_core/
error.rs

1//! Error types for the Suno engine.
2
3/// An error raised by the engine.
4#[derive(Debug, thiserror::Error)]
5pub enum Error {
6    /// The token was rejected, or no session or JWT could be obtained.
7    #[error("authentication failed: {0}")]
8    Auth(String),
9    /// A transport failure talking to Clerk or the Suno API.
10    #[error("could not connect: {0}")]
11    Connection(String),
12    /// The Suno API returned an unexpected status or body.
13    #[error("api error: {0}")]
14    Api(String),
15    /// The Suno API returned `404 Not Found` for the requested resource.
16    ///
17    /// Distinct from [`Api`](Self::Api) so a caller can treat a genuine absence
18    /// (a clip with no parent) as `None` without also swallowing a transient
19    /// `5xx`, which must surface as a real error.
20    #[error("not found: {0}")]
21    NotFound(String),
22    /// The Suno API rate-limited the request.
23    #[error("rate limited")]
24    RateLimited,
25    /// Reading or writing audio metadata tags failed.
26    #[error("tagging failed: {0}")]
27    Tag(String),
28    /// The config file could not be parsed or failed validation.
29    #[error("config error: {0}")]
30    Config(String),
31}
32
33/// A `Result` whose error is the engine [`Error`].
34pub type Result<T> = std::result::Result<T, Error>;