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

popm/wasm: add error codes #154

Merged
merged 7 commits into from
Jun 27, 2024
Merged

popm/wasm: add error codes #154

merged 7 commits into from
Jun 27, 2024

Conversation

joshuasing
Copy link
Contributor

@joshuasing joshuasing commented Jun 21, 2024

Summary
Add error codes to the WebAssembly PoP Miner.
These error codes will be used to programatically handle errors and display useful information to users.

The default error code is ErrorCodeInternal ("internal").

Changes

  • Add ErrorCode type and add Code field to the existing Error type
  • Add ErrorCodeInternal for use with internal errors (and is the default error code)
  • Add ErrorCodeInvalidValue for use when an invalid value is provided for an argument, currently only used in generateKey
  • Refactor how some elements are displayed in integration test web page to help with testing
  • Add codedError type, used to include an error code in an error that is extracted when creating an Error that will be converted to a JavaScript Object

More error codes will be added as needed in future pull requests.

web/popminer/api.go Outdated Show resolved Hide resolved
Copy link

@ArturDolzan ArturDolzan left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@marcopeereboom marcopeereboom left a comment

Choose a reason for hiding this comment

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

We need to make error code 0 "invalid". As in "it means nothing and someone did something wrong in their code" Then error codes that mean something must be != 0.

@joshuasing joshuasing merged commit be5de3b into main Jun 27, 2024
4 checks passed
@joshuasing joshuasing deleted the joshua/wasm-popm-err-code branch June 27, 2024 14:29
@joshuasing joshuasing added type: enhancement This improves existing functionality size: M This change is medium (+/- <200) area: popm/wasm This is a change to the WASM popm (PoP Miner) labels Jul 1, 2024
web3cryptoguy pushed a commit to web3cryptoguy/heminetwork that referenced this pull request Nov 1, 2024
Add error codes to the WebAssembly PoP Miner.

These error codes exposed in the NPM package for easy
programatically handling different error types.

Reviewed-on: hemilabs#154
Reviewed-by: ClaytonNorthey92 <clayton.northey@gmail.com>
Reviewed-by: Marco Peereboom <marco@peereboom.us>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: popm/wasm This is a change to the WASM popm (PoP Miner) size: M This change is medium (+/- <200) type: enhancement This improves existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants