Skip to main content

ahri_tre_app/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
4pub enum RegistrationResource {
5    Domain,
6    Study,
7}
8
9impl std::fmt::Display for RegistrationResource {
10    fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11        formatter.write_str(match self {
12            Self::Domain => "Domain",
13            Self::Study => "Study",
14        })
15    }
16}
17
18#[derive(Debug, Error)]
19pub enum AppError {
20    #[error("workflow not implemented: {0}")]
21    NotImplemented(&'static str),
22    #[error("workflow validation error: {0}")]
23    Validation(String),
24    #[error("workflow resource not found: {0}")]
25    NotFound(String),
26    #[error("workflow conflict: {0}")]
27    Conflict(String),
28    #[error("Dataset admission outcome is unresolved; output retained for reconciliation ({0:?})")]
29    DatasetAdmissionOutcomeUnknown(ahri_tre_types::VersionId),
30    #[error("workflow infrastructure error: {0}")]
31    Infrastructure(String),
32    #[error(
33        "{resource} registration failed and rollback also failed: registration={registration}; rollback={rollback}"
34    )]
35    RegistrationRollback {
36        resource: RegistrationResource,
37        #[source]
38        registration: Box<AppError>,
39        rollback: Box<AppError>,
40    },
41}