Error Codes Utility Tool 🛠

@michael has made an awesome tool to help improve troubleshooting of errors around various Layer5 Go projects.
Whenever the tool is run on a project, it analyzes the error codes in the source code, verifies them and updates or suggests changes to them so that they abide by certain best practices. It also imports the error codes so that they can be used to improve documentation.

The conventions that this utility proposes have to be enforced upon various projects and help is needed with that. To dig deeper into the subject:

Do go through this stuff and interact with the community. :grinning_face_with_smiling_eyes:

Great highlight. This error code utility auto-generates codes and their documentation (see Error Codes Reference). It’s slick.


The doc command of errorutil prints out some documentation, and is hopefully up to date.
Improvements are of course welcome :smiley: (go run doc)

For the utility to work, a few conventions have to be followed: the names of the error code variables have to match this regex: Err[A-Z].+Code. They have to be declared in files called error.go.

When instantiating errors using errors.New(...) the error code variable has to be used, using a literal code as first parameter will not be handled by the utility.

Here’s an example: meshkit/error.go at master · layer5io/meshkit · GitHub