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

chore: replacing all generic errors with FuelError #2549

Closed

Conversation

mvares
Copy link
Contributor

@mvares mvares commented Jun 18, 2024

@danielbate danielbate added the chore Issue is a chore label Jun 19, 2024
@danielbate
Copy link
Member

@msensys does this pick up all occurences?

@danielbate danielbate added this to the 0.x post-launch milestone Jun 19, 2024
Copy link
Contributor

@petertonysmith94 petertonysmith94 left a comment

Choose a reason for hiding this comment

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

@msensys does this pick up all occurences?

It believe not - hence the "Relates to"?

@danielbate danielbate marked this pull request as draft June 19, 2024 08:58
@danielbate danielbate marked this pull request as ready for review June 19, 2024 08:58
@danielbate
Copy link
Member

Sorry @msensys was just trying to validate why the validate changeset CI stage hadn't run so converted to draft

@mvares
Copy link
Contributor Author

mvares commented Jun 19, 2024

@msensys does this pick up all occurences?

Maybe not. I will send some commits to pick up all occurrences.

Copy link
Contributor

@nedsalk nedsalk 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 the work!

To fully wrap this up, can you please go to the tests that are expecting these errors and use the expectToThrowFuelError utility?

For example, for this error, there exists this test. You'd change the test to look like this:

it('throws when setting configurable but predicate has none', async () => {
  await expectToThrowFuelError(
    () =>
      new Predicate({
        bytecode: predicateBytesTrue,
        abi: predicateAbiTrue,
        provider: wallet.provider,
        inputData: ['NADA'],
        configurableConstants: {
          constant: 'NADA',
        },
      }),
    new FuelError(
      ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
      'Predicate has no configurable constants to be set'
    )
  );
});

You can do a repo-wide search for the expected error message on each error you changed and there should be a corresponding test which you'd change as shown above. If a test doesn't exist for the error, you're welcome to add it.

mvares and others added 2 commits June 20, 2024 17:48
@maschad
Copy link
Member

maschad commented Jun 20, 2024

@msensys I see that this PR still needs some work as there are quite a few places we still throw Error as opposed to FuelError (at least in 41 files). I'm going to move this PR to draft and you can re-open it to review once it's ready.

@maschad maschad marked this pull request as draft June 20, 2024 21:07
@arboleya
Copy link
Member

@msensys I see that this PR still needs some work as there are quite a few places we still throw Error as opposed to FuelError (at least in 41 files). I'm going to move this PR to draft and you can re-open it to review once it's ready.

Note that we should use the UNKNOWN code for unmapped errors.

However, to apply this, you'll need to wait until we merge this:

cc @maschad

@arboleya
Copy link
Member

arboleya commented Jun 21, 2024

Note that we should use the UNKNOWN code for unmapped errors.

Also, UNKNOWN errors must contain the rawError (see comment).

@petertonysmith94
Copy link
Contributor

@mvares did you need any assistance with this one?

@mvares
Copy link
Contributor Author

mvares commented Jun 26, 2024

@mvares did you need any assistance with this one?

Some Error class in code are related to tests. Should I change it too?

@petertonysmith94
Copy link
Contributor

@mvares did you need any assistance with this one?

Some Error class in code are related to tests. Should I change it too?

@mvares You can leave Error class usage within test files.

Copy link
Contributor

@nedsalk nedsalk 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 the work!

@nedsalk nedsalk self-requested a review July 11, 2024 11:36
@nedsalk
Copy link
Contributor

nedsalk commented Jul 11, 2024

Oops, didn't see that it's in draft 😅 I'll revoke the approval but, regardless, the PR seems good.

@maschad
Copy link
Member

maschad commented Jul 17, 2024

@mvares do you need any further guidance here? I can see doing a rudimentary search in my editor there are still quite a few places where FuelError needs to be integrated.

@mvares
Copy link
Contributor Author

mvares commented Jul 17, 2024

@maschad, sorry for about that. Currently, other issues are on my radar. I think it’s better I unassign and to close this PR.

@maschad maschad closed this Jul 17, 2024
@mvares mvares deleted the m/chore/replace-errors-to-fuelerror branch July 17, 2024 16:17
@petertonysmith94
Copy link
Contributor

There is surely value in the PR in it's current state - I'm for merging as is, and not closing the issue.

@arboleya
Copy link
Member

I couldn't agree more.

I'm afraid we can't restore branches on forks tho.

@maschad
Copy link
Member

maschad commented Jul 18, 2024

That's a good point @petertonysmith94 , @mvares if you have the branch locally you could restore it and re-open a PR, otherwise you could recreate the changes on a single commit. If you re-open the PR I suppose instead of using the Closes keyword you could use the Related keyword.

@mvares
Copy link
Contributor Author

mvares commented Jul 18, 2024

I believe I still have the branch locally. I will check it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Issue is a chore
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace all occurrences of Error to FuelError
6 participants