fluvio_smartmodule/
error.rs

1use fluvio_protocol::{Encoder, Decoder};
2
3/// Error during processing SmartModule transform error
4//
5// The presence of one of these errors most likely indicates a logic bug.
6// This error type is `#[repr(i32)]` because these errors are returned
7// as the raw return type of a SmartModule WASM function, i.e. the return
8// type in `extern "C" fn filter(ptr, len) -> i32`. Positive return values
9// indicate the numbers of records, and negative values indicate various
10// types of errors.
11//
12// THEREFORE, THE DISCRIMINANTS FOR ALL VARIANTS ON THIS TYPE MUST BE NEGATIVE
13#[repr(i32)]
14#[derive(thiserror::Error, Debug, Clone, Eq, PartialEq, Encoder, Default, Decoder)]
15#[non_exhaustive]
16#[fluvio(encode_discriminant)]
17pub enum SmartModuleTransformErrorStatus {
18    #[error("encountered unknown error during SmartModule processing")]
19    #[default]
20    UnknownError = -1,
21    #[error("failed to decode SmartModule base input")]
22    DecodingBaseInput = -11,
23    #[error("failed to decode SmartModule record input")]
24    DecodingRecords = -22,
25    #[error("failed to encode SmartModule output")]
26    EncodingOutput = -33,
27    #[error("failed to parse SmartModule extra params")]
28    ParsingExtraParams = -44,
29    #[error("undefined right record in Join SmartModule")]
30    UndefinedRightRecord = -55,
31}
32
33#[repr(i32)]
34#[derive(thiserror::Error, Debug, Clone, Eq, PartialEq, Encoder, Default, Decoder)]
35#[non_exhaustive]
36#[fluvio(encode_discriminant)]
37pub enum SmartModuleInitErrorStatus {
38    #[error("encountered unknown error during SmartModule processing")]
39    #[default]
40    UnknownError = -1,
41    #[error("Error during initialization")]
42    InitError = -2,
43    #[error("failed to decode SmartModule init input")]
44    DecodingInput = -10,
45    #[error("failed to encode SmartModule init output")]
46    EncodingOutput = -11,
47}
48
49/// Error during processing SmartModule initialization
50#[derive(thiserror::Error, Debug)]
51pub enum SmartModuleInitError {
52    #[error("Missing param {0}")]
53    MissingParam(String),
54}
55
56#[repr(i32)]
57#[derive(thiserror::Error, Debug, Clone, Eq, PartialEq, Encoder, Default, Decoder)]
58#[non_exhaustive]
59#[fluvio(encode_discriminant)]
60pub enum SmartModuleLookbackErrorStatus {
61    #[error("encountered unknown error during SmartModule processing")]
62    #[default]
63    UnknownError = -1,
64    #[error("failed to decode SmartModule look_back input")]
65    DecodingBaseInput = -66,
66    #[error("failed to decode SmartModule look_back record input")]
67    DecodingRecords = -77,
68    #[error("failed to encode SmartModule look_back output")]
69    EncodingOutput = -88,
70    #[error("Error returned from user look_back function call")]
71    PropagatedError = -99,
72}