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

Support error codes #10

Open
ndmitchell opened this issue Mar 18, 2021 · 0 comments
Open

Support error codes #10

ndmitchell opened this issue Mar 18, 2021 · 0 comments

Comments

@ndmitchell
Copy link
Contributor

Broken out from #7. @Mythra maintains a list of detailed descriptions for error codes for a project they are working on. These include error codes for Starlark errors. It would be great if Starlark could provide and integrate them, at low cost. The rough plan is:

  • Each enum variant in our error enums becomes a named error code, e.g. ValueError::IntegerOverflow might get the code STARLARK::INTEGER_OVERFLOW. For Lint errors we convert the enum into a code in a similar manner, so that code/approach can be reused.
  • We show those codes in the Diagnostic type, either optionally or always (we'll see how messy they make things, but probably always).
  • @Mythra provides a markdown file with more information on each code. One potential format would be a single error_codes.md file with section headings ## STARLARK::INTEGER_OVERFLOW followed by arbitrary markdown content about the error.
  • The Starlark library uses include_str!() to make that available, as a .describe(&self) method on Diagnostic, and also as a Diagnostic::describe_code(&str) method to enable implementing --describe=INTEGER_OVERFLOW on the command line.

While the steps are in logical order, in truth writing the Markdown file is the biggest effort by a huge margin, so that will probably come first - the actual technical tweaks are probably an hour in total, so I'll happily do them once a somewhat complete Markdown file arrives.

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

No branches or pull requests

1 participant