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

Add custom error type for broadcasting #1096

Closed
catrias opened this issue Mar 15, 2022 · 2 comments · Fixed by #1235
Closed

Add custom error type for broadcasting #1096

catrias opened this issue Mar 15, 2022 · 2 comments · Fixed by #1235
Milestone

Comments

@catrias
Copy link

catrias commented Mar 15, 2022

Stargate client broadcastTx method only provides text on error.

throw new Error(
  `Broadcasting transaction failed with code ${broadcasted.code} (codespace: ${broadcasted.codeSpace}). Log: ${broadcasted.log}`,
);

It would be useful to use some custom error class to include the code like

export class BroadcastTxError extends Error {
  constructor(public readonly code: number, message?: string) {
    super(message);
  }
}

throw new BroadcastTxError(
  broadcasted.code
  `Broadcasting transaction failed with code ${broadcasted.code} (codespace: ${broadcasted.codeSpace}). Log: ${broadcasted.log}`,
);
@webmaster128
Copy link
Member

Good idea, thanks. See #1235

@webmaster128
Copy link
Member

Shipped as part of CosmJS 0.29.0

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 a pull request may close this issue.

2 participants