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

fix: error message for provider failure was not descriptive #120

Closed

Conversation

sabotagebeats
Copy link
Contributor

What I did

fixed nondescriptive error message TypeError: Can't instantiate abstract class Infura with abstract methods chain_id
Related issue: #
#119
ApeWorX/ape-infura#1

How I did it

wrapped the offending line in try... except

How to verify it

I run ape console --network ethereum:ropsten:infura but the infura plugin is broken

Checklist

  • Passes all linting checks (pre-commit and CI jobs)
  • New test cases have been added and are passing
  • Documentation has been updated
  • PR title follows Conventional Commit standard (will be automatically included in the changelog)

@sabotagebeats sabotagebeats self-assigned this Aug 3, 2021
self.providers[provider_name](provider_settings=provider_settings),
)
except TypeError as e:
raise Exception(f"Plugin {provider_name} failed to load!")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I left it as Exception for consistency with the rest of the file, should I refactor it to Abort?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

e is not used, I could include it something like:

except TypeError as e:
    raise Exception(f"Plugin {provider_name} failed to load!",e)```

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this also doesn't note the failure and skip loading that plugin module.

Copy link
Member

Choose a reason for hiding this comment

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

Let's talk more about how to fix this one

try:
return ProviderContextManager(
self.ecosystem.network_manager,
self.providers[provider_name](provider_settings=provider_settings),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wrapped the return statement, since I wasn't sure how to wrap just the one argument.

Copy link
Member

Choose a reason for hiding this comment

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

More like this (pull out the statement that needs the try...except)

try:
    provider = self.providers[provider_name](provider_settings=provider_settings)
 ...
 
return ProviderContextManager(
    ...,
    provider,
    ...,
)

@fubuloubu
Copy link
Member

closing in favor of #121

@fubuloubu fubuloubu closed this Aug 3, 2021
@sabotagebeats sabotagebeats deleted the fix/infura-provider branch October 22, 2021 09:56
@sabotagebeats sabotagebeats restored the fix/infura-provider branch October 22, 2021 09:56
@sabotagebeats sabotagebeats deleted the fix/infura-provider branch October 22, 2021 09:57
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