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

Add causes parameter to fail and use it for extension tags #17889

Closed
wants to merge 3 commits into from

Commits on Mar 28, 2023

  1. Configuration menu
    Copy the full SHA
    bc7a2a6 View commit details
    Browse the repository at this point in the history
  2. Add causes parameter to fail

    The new parameter makes it possiblt to fail in a way that is more
    appropriate for user errors: No Starlark stack trace is prepended to the
    failure, instead the provided causes and their locations are appended to
    the error message.
    fmeum committed Mar 28, 2023
    Configuration menu
    Copy the full SHA
    9b8a063 View commit details
    Browse the repository at this point in the history
  3. Make TypeCheckedTag a FailureCause

    By passing the Starlark representation of a module extension tag to
    the new `causes` parameter of `fail`, module extensions can generate
    more concise and helpful error messages on user errors.
    
    Before:
    ```
    ERROR: Traceback (most recent call last):
    	File "/home/user/.cache/bazel/_bazel_user/466e6feac151a1e22847383f4e503361/external/gazelle~override/internal/bzlmod/go_deps.bzl", line 165, column 21, in _go_deps_impl
    		fail("Multiple overrides defined for Go module path \"{}\" in module \"{}\".".format(override_tag.path, module.name))
    Error in fail: Multiple overrides defined for Go module path "github.com/stretchr/testify" in module "gazelle_bcr_tests".
    ```
    
    After:
    ```
    ERROR: Multiple overrides defined for Go module path "github.com/stretchr/testify" in module "gazelle_bcr_tests".
    Causes:
    	bazel_module_tag in file "<root>/MODULE.bazel", line 39, column 25, with value:
    		go_deps.gazelle_override(
    		    path = "github.com/stretchr/testify",
    		    directives = ["gazelle:go_naming_convention go_default_library"],
    		)
    ```
    fmeum committed Mar 28, 2023
    Configuration menu
    Copy the full SHA
    8346e89 View commit details
    Browse the repository at this point in the history