Skip to content

Produce structured error for unknown module #4684

@VeryMilkyJoe

Description

@VeryMilkyJoe

Currently we need to use a regex to figure out whether an error message relates to an unknown module.
With a structured erro, we could handle this in a cleaner and safer way.

We are currently generating it like this:

unknownModuleMessage :: String -> [String]
unknownModuleMessage moduleFileName =
  [ "Loading the module '" <> moduleFileName <> "' failed."
  , ""
  , "It may not be listed in your .cabal file!"
  , "Perhaps you need to add `"<> dropExtension (takeFileName moduleFileName) <> "` to other-modules or exposed-modules."
  , ""
  , "For more information, visit: https://cabal.readthedocs.io/en/3.4/developing-packages.html#modules-included-in-the-package"
  ]

Specifically, this would help in the new cabal-add-module code action, where I had to parse the string using a regex.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions