How to create a custom error code in Meshery Server?

I want to create a custom error to be returned from a handler in Meshery Server when I’m unable to fetch a performance profile from a provider. For that purpose I have to go into server/handlers/error.go to create a new error code. What is the convention when creating a new error code ? I’m aware that we are currently trying to fix duplicate error codes in different areas of Meshery. How does one avoid that ?

1 Like

Great question.

Here is a quick link in the docs that explains this: How to write MeshKit compatible errors | Meshery. (though might be outdated a bit)

Generally, you need to ensure that the new error code you create should be unique throughout all the error.go files defined in Meshery component (which would be Meshery Server for your case).

You can do make error to confirm the duplicity of your new error code