Skip to content
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

Implement BlockNotFoundError #189

Merged
merged 2 commits into from
Jul 16, 2024
Merged

Implement BlockNotFoundError #189

merged 2 commits into from
Jul 16, 2024

Conversation

selankon
Copy link
Collaborator

On this way we can create a more verbose output for not found blocks when trying to access them by blockList.

This is not necessary at all since Gui told me that they are fixing the way of how old blocks will be indexed, so this should not be necessary anymore on the explorer. But, just in case, the change is not really big and we could use it from now and will prevent future pruned blocks that are not indexed properly.

The question here is if simply return a more generic error type (not only for the 404 blocks).

@selankon selankon marked this pull request as ready for review July 16, 2024 14:03
@selankon selankon requested a review from elboletaire July 16, 2024 14:03
@selankon
Copy link
Collaborator Author

selankon commented Jul 16, 2024

FTR another way to do the same:

return Promise.allSettled(promises).then((results) => {
    const success: IChainBlockInfoResponse[] = []
    const errors: { index: number, error: any }[] = []

    results.forEach((result, index) => {
      if (result.status === "fulfilled") {
        success.push(result.value)
      } else {
        // Capture 404 errors specifically
        if (result.reason?.response?.status === 404) {
          errors.push({ index, error: result.reason })
        }
      }
    })

@elboletaire elboletaire merged commit 04d0df4 into main Jul 16, 2024
1 check passed
@elboletaire elboletaire deleted the f/implement-block-errors branch July 16, 2024 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants