superstream/
error.rs

1//! Module for superstream error handling.
2
3use anchor_lang::prelude::*;
4
5/// Enumeration of possible stream errors.
6#[error_code]
7pub enum StreamError {
8    /// The stream recipient is empty. Should be a valid address.
9    #[msg("The stream recipient is empty. Should be a valid address")]
10    EmptyRecipient,
11    /// The stream recipient is the same as the sender. Should be different addresses.
12    #[msg("The stream recipient is the same as the sender. Should be different addresses")]
13    SameSenderAndRecipient,
14    /// The stream sender is the same as the new sender. Should be different addresses.
15    #[msg("The stream sender is the same as the new sender. Should be different addresses")]
16    SameSenders,
17    /// The stream recipient is the same as the new recipient. Should be different addresses.
18    #[msg("The stream recipient is the same as the new recipient. Should be different addresses")]
19    SameRecipients,
20    /// The new sender is invalid.
21    #[msg("The new sender is invalid")]
22    InvalidNewSender,
23    /// The sender is invalid.
24    #[msg("The sender is invalid")]
25    InvalidSender,
26    /// The recipient is invalid.
27    #[msg("The recipient is invalid")]
28    InvalidRecipient,
29    /// The stream name is too short. Should be >= 2 chars.
30    #[msg("The stream name is too short. Should be >= 2 chars")]
31    StreamNameTooShort,
32    /// The stream name is too long. Should be <= 100 chars.
33    #[msg("The stream name is too long. Should be <= 100 chars")]
34    StreamNameTooLong,
35    /// The flow interval is 0. Should be > 0.
36    #[msg("The flow interval is 0. Should be > 0")]
37    ZeroFlowInterval,
38    /// The end time is either 0 with prepaid = true, in the past or < starts_at. Should be >= current_time and
39    /// >= starts_at or if the stream is not prepaid, it can be 0.
40    #[msg("The end time is either 0 with prepaid = true, in the past or < starts_at. Should be >= current_time and >= starts_at or if the stream is not prepaid, it can be 0")]
41    InvalidEndsAt,
42    /// The stream will never lead to any payments. Either there should be a initial amount or flow rate and flow
43    /// duration should be > 0.
44    #[msg("The stream will never lead to any payments. Either there should be a initial amount or flow rate and flow duration should be > 0")]
45    ZeroLifetimeAmount,
46    /// The amount cannot be 0. Should be > 0.
47    #[msg("The amount cannot be 0. Should be > 0")]
48    ZeroAmount,
49    /// The prepaid amount needed by the stream is out of bounds.
50    #[msg("The prepaid amount needed by the stream is out of bounds")]
51    PrepaidAmountNeededOutOfBounds,
52    /// The deposit amount needed by the non-prepaid stream is out of bounds.
53    #[msg("The deposit amount needed by the non-prepaid stream is out of bounds")]
54    DepositAmountNeededOutOfBounds,
55    /// The amount is less than the minimum initial amount needed.
56    #[msg("The amount is less than the minimum initial amount needed")]
57    AmountLessThanAmountNeeded,
58    /// The user is not allowed to withdraw. Should be the recipient of the stream.
59    #[msg("The user is not allowed to withdraw. Should be the recipient of the stream")]
60    UserUnauthorizedToWithdraw,
61    /// The withdrawn amount by recipient is more than the amount owed. THIS SHOULD NOT HAVE HAPPENED!!!
62    #[msg("The withdrawn amount by recipient is more than the amount owed. THIS SHOULD NOT HAVE HAPPENED!!!")]
63    WithdrawnAmountGreaterThanAmountOwed,
64    /// The total withdrawn amount by the recipient of the stream is out of bounds.
65    #[msg("The total withdrawn amount by the recipient of the stream is out of bounds")]
66    WithdrawAmountOutOfBounds,
67    /// The amount available to be withdrawn by the recipient of the stream is out of bounds.
68    #[msg("The amount available to be withdrawn by the recipient of the stream is out of bounds")]
69    AmountAvailableToWithdrawOutOfBounds,
70    /// The cancellation refund amount to the sender of the stream is out of bounds.
71    #[msg("The cancellation refund amount to the sender of the stream is out of bounds")]
72    CancellationRefundOutOfBounds,
73    /// The total topup amount by the sender of the stream is out of bounds.
74    #[msg("The total topup amount by the sender of the stream is out of bounds")]
75    TopupAmountOutOfBounds,
76    /// The topup amount is more than what is needed by the stream.
77    #[msg("The topup amount is more than what is needed by the stream")]
78    TopupAmountMoreThanMaxAcceptable,
79    /// The sender has insufficient balance in their token account.
80    #[msg("The sender has insufficient balance in their token account")]
81    SenderInsufficientFunds,
82    /// The token escrow account has insufficient balance. THIS SHOULD NOT HAVE HAPPENED!!!
83    #[msg("The token escrow account has insufficient balance. THIS SHOULD NOT HAVE HAPPENED!!!")]
84    EscrowInsufficientFunds,
85    /// The token escrow account is not rent exempt.
86    #[msg("The token escrow account is not rent exempt")]
87    EscrowNotRentExempt,
88    /// The stream has already been cancelled.
89    #[msg("The stream has already been cancelled")]
90    StreamAlreadyCancelled,
91    /// The user is not allowed to cancel. Should be the sender or the recipient of the stream.
92    #[msg("The user is not allowed to cancel. Should be the sender or the recipient of the stream")]
93    UserUnauthorizedToCancel,
94    /// The sender is not allowed to cancel permanently or at the moment.
95    #[msg("The sender is not allowed to cancel permanently or at the moment")]
96    SenderCannotCancel,
97    /// The stream is prepaid. Should be a non-prepaid stream.
98    #[msg("The stream is prepaid. Should be a non-prepaid stream")]
99    StreamIsPrepaid,
100    /// The stream has already stopped. Should be an unstopped stream.
101    #[msg("The stream has already stopped. Should be an unstopped stream")]
102    StreamHasStopped,
103    /// The stream is already paused. Should be a non-paused stream.
104    #[msg("The stream is already paused. Should be a non-paused stream")]
105    StreamIsPaused,
106    /// The stream is not paused. Should be a paused stream.
107    #[msg("The stream is not paused. Should be a paused stream")]
108    StreamIsNotPaused,
109    /// The stream has no flow payments. Should be a stream stream with a positive flow rate and flow period.
110    #[msg("The stream has no flow payments. Should be a stream stream with a positive flow rate and flow period")]
111    StreamHasNoFlowPayments,
112    /// The sender is not allowed to change sender of the stream permanently or at the moment.
113    #[msg("The sender is not allowed to change sender of the stream permanently or at the moment")]
114    SenderCannotChangeSender,
115    /// The sender is not allowed to pause stream permanently or at the moment.
116    #[msg("The sender is not allowed to pause stream permanently or at the moment")]
117    SenderCannotPause,
118    /// The recipient is not allowed resume a stream paused by sender permanently or at the moment.
119    #[msg("The recipient is not allowed resume a stream paused by sender permanently or at the moment")]
120    RecipientCannotResumePauseBySender,
121    /// The user is not allowed to pause. Should be the sender or the recipient of the stream.
122    #[msg("The user is not allowed to pause. Should be the sender or the recipient of the stream")]
123    UserUnauthorizedToPause,
124    /// The user is not allowed to resume. Should be the sender or the recipient of the stream.
125    #[msg("The user is not allowed to resume. Should be the sender or the recipient of the stream")]
126    UserUnauthorizedToResume,
127    /// The stream has not ended. Should have ended and nat been cancelled.
128    #[msg("The stream has not ended. Should have ended and nat been cancelled")]
129    StreamNotEnded,
130}