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

feat: surfacing error message returned from relayer #861

Merged

Conversation

scastleman-immutable
Copy link
Contributor

Summary

The imGetTransactionByHash method now returns an additional statusMessage field on transaction failure, which contains information about the cause of the error. This PR captures that message and returns it to the end user.

Why the changes

This helps convey the specific reason a request failed so that the end user can better respond to the probelm.

Things worth calling out

The error test in sendTransaction.test.ts has been updated to ensure this message is being returned, however I couldn't find a way to trigger an actual error in live testing, so there may be edge cases I was not able to capture.

Comment on lines 128 to 129
`Transaction failed to submit with status ${relayerTransaction.status}. `
+ `Error message: ${relayerTransaction.statusMessage}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think the statusMessage is always set 🤔 Can we update this to handle this scenario? And can I suggest we simplify the message a little bit here, e.g.:

let errorMessage = `Transaction failed to submit with status ${relayerTransaction.status}`;
if (relayerTransaction.statusMessage) {
  errorMessage += `: ${relayerTransaction.statusMessage}`;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call. I've added your logic there, and also changed the RelayerTransaction interface so that statusMessage is optional.

@@ -123,9 +123,13 @@ export const sendTransaction = ({
RelayerTransactionStatus.SUBMITTED,
RelayerTransactionStatus.SUCCESSFUL,
].includes(relayerTransaction.status)) {
let errorMessage = `Transaction failed to submit with status ${relayerTransaction.status}.`;
if (!relayerTransaction.statusMessage) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (!relayerTransaction.statusMessage) {
if (relayerTransaction.statusMessage) {

@haydenfowler haydenfowler marked this pull request as ready for review September 26, 2023 05:31
@haydenfowler haydenfowler requested a review from a team as a code owner September 26, 2023 05:31
@scastleman-immutable scastleman-immutable merged commit 6ee77f5 into main Sep 26, 2023
6 checks passed
@scastleman-immutable scastleman-immutable deleted the feature/ID-1049-relay-error-message-surfacing branch September 26, 2023 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants