-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add memory cache and refacto some stuff (#45)
* feat: log -> tracing * fix: improve error log * cleanup * feat: query defillama api util * remove print * feat: add memory cache for defillama
- Loading branch information
Showing
15 changed files
with
500 additions
and
232 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,31 @@ | ||
use std::{error::Error as StdError, fmt}; | ||
|
||
use diesel::result::Error as DieselError; | ||
use diesel_async::pooled_connection::deadpool::PoolError; | ||
use starknet::providers::ProviderError; | ||
use thiserror::Error; | ||
|
||
#[derive(Debug)] | ||
#[derive(Error, Debug)] | ||
pub enum MonitoringError { | ||
#[error("Price error: {0}")] | ||
Price(String), | ||
Database(diesel::result::Error), | ||
Connection(diesel_async::pooled_connection::deadpool::PoolError), | ||
|
||
#[error("Database error: {0}")] | ||
Database(#[from] DieselError), | ||
|
||
#[error("Connection error: {0}")] | ||
Connection(#[from] PoolError), | ||
|
||
#[error("API error: {0}")] | ||
Api(String), | ||
|
||
#[error("Conversion error: {0}")] | ||
Conversion(String), | ||
|
||
#[error("OnChain error: {0}")] | ||
OnChain(String), | ||
Provider(ProviderError), | ||
InvalidTimestamp(u64), | ||
} | ||
|
||
impl StdError for MonitoringError {} | ||
|
||
impl fmt::Display for MonitoringError { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
match self { | ||
MonitoringError::Price(e) => write!(f, "Price Error: {}", e), | ||
MonitoringError::Database(e) => write!(f, "Database Error: {}", e), | ||
MonitoringError::Connection(e) => write!(f, "Connection Error: {}", e), | ||
MonitoringError::Api(e) => write!(f, "API Error: {}", e), | ||
MonitoringError::Conversion(e) => write!(f, "Conversion Error: {}", e), | ||
MonitoringError::OnChain(e) => write!(f, "OnChain Error: {}", e), | ||
MonitoringError::Provider(e) => write!(f, "Provider Error: {}", e), | ||
MonitoringError::InvalidTimestamp(e) => write!(f, "Invalid Timestamp: {}", e), | ||
} | ||
} | ||
} | ||
#[error("Provider error: {0}")] | ||
Provider(#[from] ProviderError), | ||
|
||
// Convert diesel error to our custom error | ||
impl From<diesel::result::Error> for MonitoringError { | ||
fn from(err: diesel::result::Error) -> MonitoringError { | ||
MonitoringError::Database(err) | ||
} | ||
#[error("Invalid timestamp: {0}")] | ||
InvalidTimestamp(u64), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.