batch_mode_batch_reconciliation/
errors.rs

1// ---------------- [ File: batch-mode-batch-reconciliation/src/errors.rs ]
2crate::ix!();
3
4error_tree!{
5
6    pub enum BatchOutputProcessingError {
7        ErrorSavingFailedBatchEntries(ErrorSavingFailedBatchEntries),
8        JsonParseError(JsonParseError),
9        BatchWorkspaceError(BatchWorkspaceError),
10        IoError(std::io::Error),
11        SerializationError(serde_json::Error),
12        MissingFilePath,
13    }
14
15    pub enum ErrorSavingFailedBatchEntries {
16        SerdeJsonError(serde_json::Error),
17        IoError(std::io::Error),
18    }
19
20    pub enum BatchReconciliationError {
21        BatchWorkspaceError(BatchWorkspaceError),
22        OpenAIClientError(OpenAIClientError),
23        BatchMetadataError(BatchMetadataError),
24        IOError(std::io::Error),
25        BatchDownloadError(BatchDownloadError),
26        BatchValidationError(BatchValidationError),
27        BatchErrorProcessingError(BatchErrorProcessingError),
28        BatchOutputProcessingError(BatchOutputProcessingError),
29        FileMoveError(FileMoveError),
30
31        #[display("BatchReconciliationError: operation not implemented. operation={operation:?}")]
32        OperationNotImplemented {
33            operation: BatchFileTripleReconciliationOperation,
34        },
35
36        #[display("BatchReconciliationError: reconciliation failed. index={index:?}")]
37        ReconciliationFailed {
38            index:  BatchIndex,
39            //errors: Vec<(BatchFileTripleReconciliationOperation,BatchReconciliationError)>,
40        },
41
42        #[display("BatchReconciliationError: missing input file. index={index:?}, output={output:?}, error={error:?}")]
43        MissingBatchInputFileButOthersExist {
44            index:  BatchIndex,
45            output: Option<PathBuf>,
46            error:  Option<PathBuf>,
47        },
48    }
49
50    pub enum BatchSuccessResponseHandlingError {
51        UuidParseError(UuidParseError),
52        JsonParseError(JsonParseError),
53        SerdeJsonError(serde_json::Error),
54        TokenParseError(TokenParseError),
55        SaveLoadError(SaveLoadError),
56        IoError(std::io::Error),
57    }
58}
59
60impl From<BatchReconciliationError> for MockBatchClientError {
61    fn from(e: BatchReconciliationError) -> Self {
62        MockBatchClientError::BatchReconciliationError { index: e.index().expect("todo: checkme") }
63    }
64}
65
66impl From<BatchOutputProcessingError> for MockBatchClientError {
67    fn from(_e: BatchOutputProcessingError) -> Self {
68        MockBatchClientError::BatchOutputProcessingError
69    }
70}
71
72impl BatchReconciliationError {
73    pub fn index(&self) -> Option<BatchIndex> {
74        match self {
75            BatchReconciliationError::ReconciliationFailed { index } => {
76                Some(index.clone())
77            }
78
79            BatchReconciliationError::MissingBatchInputFileButOthersExist { index, output: _, error: _ } => {
80                Some(index.clone())
81            }
82            _ => None
83        }
84    }
85}