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

refactor: add MarketError #670

Merged

Conversation

emizzle
Copy link
Contributor

@emizzle emizzle commented Jan 10, 2024

Add MarketError and convert all EthersErrors (ProviderError, SignerError) to MarketError

Note

Based on branch of PR #662.

Copy link
Member

@markspanbroek markspanbroek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, thanks @emizzle!


convertEthersError:
let subscription = await market.contract.subscribe(ProofSubmitted, onEvent)
return OnChainMarketSubscription(eventSubscription: subscription)

method unsubscribe*(subscription: OnChainMarketSubscription) {.async.} =
await subscription.eventSubscription.unsubscribe()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should probably also be wrapped in convertEthersError?

@dryajov
Copy link
Contributor

dryajov commented Jan 11, 2024

Wouldn't it be better/safer to return a Result instead of converting to another exception?

@emizzle
Copy link
Contributor Author

emizzle commented Jan 15, 2024

Wouldn't it be better/safer to return a Result instead of converting to another exception?

@dryajov Well, that's an interesting yet difficult question to answer, as we've discussed in the past. Would you prefer that Result is returned here?

Given that there's only one place that catches MarketError as of right now, I don't necessarily see the benefit yet, however, if there were to be more call sites that would indeed need to catch a MarketError in the future, then I agree it could be beneficial.

If we changed to return a Result now, every existing call site would need to be updated, and likely, in most instances, the error returned in the Result would simply be logged. Otherwise, the function containing the call site would also need to return a Result, spreading it further up the stack. I'm certainly not opposed to the spread, but it would be a fair amount of change, so maybe it's a good idea if we (and others) agree on it before the work is undertaken?

@dryajov
Copy link
Contributor

dryajov commented Jan 16, 2024

If we changed to return a Result now, every existing call site would need to be updated, and likely, in most instances, the error returned in the Result would simply be logged. Otherwise, the function containing the call site would also need to return a Result, spreading it further up the stack. I'm certainly not opposed to the spread, but it would be a fair amount of change, so maybe it's a good idea if we (and others) agree on it before the work is undertaken?

Sure, if the change cascades too many other changes, it might not be worth it.

Overall I've since come around with the usage of result. I think the argument in are still valid (from both ends of the spectrum), but specifically to the ergonomics of result, things have improved (with ? and questionable). I believe that recent versions of chronos now also support ? in async code, which should make our async code a lot less verbose. All in all, results are easier to track and reason about.

@emizzle emizzle force-pushed the refactor/integration/multi-node-integration-tests branch from eeead89 to 2493357 Compare January 22, 2024 03:13
@emizzle emizzle force-pushed the refactor/integration/multi-node-integration-tests branch 2 times, most recently from e3b505a to 9d7b0dd Compare February 16, 2024 11:06
@dryajov dryajov force-pushed the refactor/integration/multi-node-integration-tests branch from 5ce32c9 to 555d2a7 Compare February 16, 2024 22:48
Base automatically changed from refactor/integration/multi-node-integration-tests to master February 19, 2024 05:18
@emizzle emizzle closed this Mar 18, 2024
@emizzle emizzle force-pushed the refactor/marketplace/convert-etherserror-to-marketerror branch from cf827a8 to d33804f Compare March 18, 2024 05:28
Add MarketError and convert all EthersErrors (ProviderError, SignerError) to MarketError
@emizzle emizzle reopened this Mar 18, 2024
@emizzle
Copy link
Contributor Author

emizzle commented Mar 18, 2024

Sure, if the change cascades too many other changes, it might not be worth it.

@dryajov I had a look at this, and I think for now, the changes this would introduce would be too many for the benefit. Perhaps we should create an issue and handle this another time?

@emizzle emizzle added this pull request to the merge queue Mar 21, 2024
Merged via the queue into master with commit 43f0bf1 Mar 21, 2024
10 checks passed
@emizzle emizzle deleted the refactor/marketplace/convert-etherserror-to-marketerror branch March 21, 2024 01:23
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.

4 participants