fuel_streams_core/stream/
error.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use async_nats::{
    error,
    jetstream::{
        consumer::StreamErrorKind,
        context::{CreateKeyValueErrorKind, CreateStreamErrorKind},
        kv::{CreateError, CreateErrorKind, PutError, WatchErrorKind},
        stream::{ConsumerErrorKind, LastRawMessageErrorKind},
    },
};
use displaydoc::Display as DisplayDoc;
use thiserror::Error;

#[derive(Error, DisplayDoc, Debug)]
pub enum StreamError {
    /// Failed to publish to stream: {subject_name}
    PublishFailed {
        subject_name: String,
        #[source]
        source: error::Error<CreateErrorKind>,
    },

    /// Failed to retrieve last published message from stream
    GetLastPublishedFailed(#[from] error::Error<LastRawMessageErrorKind>),

    /// Failed to create Key-Value Store
    StoreCreation(#[from] error::Error<CreateKeyValueErrorKind>),

    /// Failed to publish item to Key-Value Store
    StorePublish(#[from] PutError),

    /// Failed to subscribe to subject in Key-Value Store
    StoreSubscribe(#[from] error::Error<WatchErrorKind>),

    /// Failed to publish item to stream
    StreamPublish(#[from] CreateError),

    /// Failed to create stream
    StreamCreation(#[from] error::Error<CreateStreamErrorKind>),

    /// Failed to create consumer for stream
    ConsumerCreate(#[from] error::Error<ConsumerErrorKind>),

    /// Failed to consume messages from stream
    ConsumerMessages(#[from] error::Error<StreamErrorKind>),
}