Skip to main content

reifydb_sub_flow/
error.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright (c) 2026 ReifyDB
3
4use reifydb_cdc::error::CdcError;
5use reifydb_core::error::diagnostic::flow::{
6	extern_abi_tag_mismatch, extern_create_failed, extern_library_not_loaded, extern_operator_not_found,
7	extern_symbol_not_found, flow_catch_up_read_failed,
8};
9use reifydb_value::error::{Diagnostic, Error, IntoDiagnostic};
10
11#[derive(Debug, thiserror::Error)]
12pub enum FlowLoadError {
13	#[error("cdc catch-up read for versions ({from}, {up_to}] failed: {cause}")]
14	Read {
15		from: u64,
16		up_to: u64,
17		cause: CdcError,
18	},
19}
20
21impl IntoDiagnostic for FlowLoadError {
22	fn into_diagnostic(self) -> Diagnostic {
23		match self {
24			FlowLoadError::Read {
25				from,
26				up_to,
27				cause,
28			} => flow_catch_up_read_failed(from, up_to, &cause.to_string()),
29		}
30	}
31}
32
33impl From<FlowLoadError> for Error {
34	fn from(err: FlowLoadError) -> Self {
35		Error(Box::new(err.into_diagnostic()))
36	}
37}
38
39#[derive(Debug, thiserror::Error)]
40pub enum ExternOperatorError {
41	#[error("extern operator ABI tag mismatch: plugin {plugin:#06x}, host {host:#06x}")]
42	AbiTagMismatch {
43		plugin: u32,
44		host: u32,
45	},
46
47	#[error("extern operator library not loaded: {path}")]
48	LibraryNotLoaded {
49		path: String,
50	},
51
52	#[error("extern operator symbol '{symbol}' not found: {cause}")]
53	SymbolNotFound {
54		symbol: &'static str,
55		cause: String,
56	},
57
58	#[error("extern operator '{operator}' not found")]
59	OperatorNotFound {
60		operator: String,
61	},
62
63	#[error("failed to create extern operator: {cause}")]
64	CreateFailed {
65		cause: String,
66	},
67}
68
69impl IntoDiagnostic for ExternOperatorError {
70	fn into_diagnostic(self) -> Diagnostic {
71		match self {
72			ExternOperatorError::AbiTagMismatch {
73				plugin,
74				host,
75			} => extern_abi_tag_mismatch(plugin, host),
76			ExternOperatorError::LibraryNotLoaded {
77				path,
78			} => extern_library_not_loaded(&path),
79			ExternOperatorError::SymbolNotFound {
80				symbol,
81				cause,
82			} => extern_symbol_not_found(symbol, cause),
83			ExternOperatorError::OperatorNotFound {
84				operator,
85			} => extern_operator_not_found(&operator),
86			ExternOperatorError::CreateFailed {
87				cause,
88			} => extern_create_failed(cause),
89		}
90	}
91}
92
93impl From<ExternOperatorError> for Error {
94	fn from(err: ExternOperatorError) -> Self {
95		Error(Box::new(err.into_diagnostic()))
96	}
97}