Replies: 4 comments
-
Then just don't panic and handle the error? |
Beta Was this translation helpful? Give feedback.
0 replies
-
How to catch the error when database lost?
|
Beta Was this translation helpful? Give feedback.
0 replies
-
I want to fulfill this: |
Beta Was this translation helpful? Give feedback.
0 replies
-
#[derive(Clone)]
struct DbPool {
pool: Option<SqlPool>
}
impl DbPool {
async fn init() -> Self {
let pool = db::db_init().await {
Ok(ppool => Some(pool),
Err(e) => {
error!("{:?}", e);
None
};
Self { pool }
}
fn try_get(&self) -> Option<&SqlPool> {
self.pool.as_deref()
}
} Use Option and Result type to represent a possible or branched on error type. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I use mysql for database, when the connect timeout, the panic will stop the main.
Actually, the database connection is not so important, I want to main can alive even the connection is lost.
Is there any solution?
error info
Beta Was this translation helpful? Give feedback.
All reactions