Return proper error to CLI for all expected scenarios

When a CLI requests a spot price have some errors that are expected, where we can provide a proper error message for the CLI:
- Balance of ASB too low
- Buy amount sent by CLI exceeds maximum buy amount accepted by ASB
- ASB is running in maintenance mode and does not accept incoming swap requests

All of these errors returns a proper error to the CLI and prints a warning in the ASB logs.
Any other unexpected error will result in closing the channel with the CLI and printing an error in the ASB logs.
This commit is contained in:
Daniel Karzel 2021-04-30 12:36:26 +10:00
parent f6497778ed
commit ea76ae5821
No known key found for this signature in database
GPG key ID: 30C3FC2E438ADB6E
5 changed files with 55 additions and 53 deletions

View file

@ -192,12 +192,6 @@ pub struct InsufficientFunds {
pub actual: Amount,
}
#[derive(Debug, Clone, Copy, thiserror::Error)]
#[error("The balance is too low, current balance: {balance}")]
pub struct BalanceTooLow {
pub balance: Amount,
}
#[derive(thiserror::Error, Debug, Clone, PartialEq)]
#[error("Overflow, cannot convert {0} to u64")]
pub struct OverflowError(pub String);