Skip to content

Better Error handler#109

Merged
nepoche merged 26 commits into
developfrom
ahmed.better-error-handler
Jun 28, 2021
Merged

Better Error handler#109
nepoche merged 26 commits into
developfrom
ahmed.better-error-handler

Conversation

@AhmedKorim
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Contributor

@drewstone drewstone left a comment

Choose a reason for hiding this comment

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

Thanks for adding comments to the code, it's really helpful!

The design of this seems great and well-intentioned. I am not sure about adding hardcoded delays into the code as that does seem like something we should avoid. How and why are we not able to wait until certain processes are loaded? A 3 second delay seems arbitrary and could provide issues in the future.

It seems we're just using this error handler in api init correct? Just want to make sure I'm forming a good mental model. The plan is to use this everywhere we have errors right?

Comment thread packages/apps/src/App.tsx Outdated
id: 1,
group: 'edgware',
tag: 'dev',
evmId: undefined,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we use enums then we should make sure:

  • Edgeware mainnet is 2021
  • Edgeware beresheet is 2022

Copy link
Copy Markdown
Contributor Author

@AhmedKorim AhmedKorim Jun 28, 2021

Choose a reason for hiding this comment

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

Will handle this on a refactor PR after the merge for #111

const [apiPromise, injectedExtension] = await PolkadotProvider.getParams(appName, endpoints);
async awaitMetaDataCheck() {
/// delay some time till the UI is instantiated and then check if the dApp needs to update extension meta data
await new Promise((r) => setTimeout(r, 3000));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This isn't great practice, can we remove this? What errors occur when you do?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is checking for the metadata update(which isn't really urgent at init) doing timeout will make this task of a lower priority although timeout of 0 is enough,so by the time the timeout is done the UI would have been initialized instead of UI freezes, Polkadot ApiPromise seems heavy already it freezes the UI for 2 seconds just don't wont to add to this as the update metadata will trigger a modal, But I hear you will test it more and improve it

let interActiveFeedback: InterActiveFeedback;
const body = InterActiveFeedback.feedbackEntries([
{
header: 'Failed to establish WS connection',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we should probably abstract all our error messages into a common folder/location as well and use Enums.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@AhmedKorim AhmedKorim requested a review from nepoche June 28, 2021 20:05
webbWeb3Provider.on('providerUpdate', async ([chainId]) => {
const nextChain = Object.values(chains).find((chain) => chain.evmId === chainId);
if (!nextChain) {
try {
Copy link
Copy Markdown
Contributor

@nepoche nepoche Jun 28, 2021

Choose a reason for hiding this comment

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

Should we be trying anything if we do not support the evm chain id? can we just put the entire catch block with case: UnsupportedChain here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this call WebbWeb3Provider.storageName(chainId) will throw UnsupportedChain Error catching this and show an interactiveFeedback

@nepoche nepoche changed the base branch from master to develop June 28, 2021 22:06
…-handler

# Conflicts:
#	packages/react-environment/src/WebbProvider.tsx
#	packages/react-environment/src/api-providers/web3/webb-web3-provider.ts
@nepoche nepoche merged commit 249e0a9 into develop Jun 28, 2021
@dutterbutter dutterbutter deleted the ahmed.better-error-handler branch October 26, 2022 01: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.

3 participants