proposal: implement `Error` interface for error types

Open
#328 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
go
Domain
api

Research direction

Start by reading issue #127 and locating the error types and SDK helper shown in this issue. Determine which error values need Error methods and verify that SDK callers can return them directly; replacing hyphens with spaces is optional.

Written by the indexing model from the issue text.

Description

building upon #127, can we add an Error method to error types so that in our sdk's we can directly return the error instead of having to map it to error msgs manually.

e.g. following method in the sdk could be just removed if we had that.

func errorVariantToError(err abc.Error) error {
	switch {
	case abc.ErrorInputNotSupported() == err:
		return fmt.Errorf("input not supported")
	case abc.RuntimeError() == err:
		return fmt.Errorf("runtime error")
	case abc.InvalidInput() == err:
		return fmt.Errorf("invalid input")
	default:
		return fmt.Errorf("no error provided by host implementation")
	}
}

Another thing we could possibly do is to replace "-" with " " automatically (to make it more readable), but its just a nice to have item.

Dominant language
Go
Stars
148
Forks
20
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bytecodealliance/go-modules

All issues in bytecodealliance/go-modules

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.