-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove ?
operators with checks, to reduce crashing
#5
Comments
This is simply not the case, we're exiting the current loop and passing an Err enum variant up the callstack. This can be handled by anyone further up the chain who wants to handle it, and we do! See croncat-indexer/src/indexer/system.rs Lines 196 to 215 in feb6eea
We handle the error, tell the user we got it and what it was. Then we retry getting more blocks from the chain, if we miss a block or 2 (which can absolutely happen considering the connection goes down 4 times a day) this task picks up the slack: croncat-indexer/src/indexer/system.rs Lines 228 to 252 in feb6eea
Which once again, handles intermittent errors and retries if it fails. |
I think we might need to be careful about using the
?
operator for long-running tasks like the agent and indexer.This is a pretty good rundown:
https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html#a-shortcut-for-propagating-errors-the--operator
It's basically like, "something happened that means we gotta stop"
In the function below, for instance, here's an example:
croncat-indexer/src/streams/block.rs
Line 84 in feb6eea
This is in a while loop, and if a
block
variable comes in with an error, we're instructing the application to throw an error and exit.I think we'll need to replace this with a
match
statement that checks forOk
orErr
and on error, perhaps log it (optional) or justcontinue
on with the while loop.I see in that same function
ws_block_stream
there are a few more places where we have the pattern to throw an error and crash the program, but I think those also need to be dealt with in a way that doesn't stop execution.The text was updated successfully, but these errors were encountered: