-
Notifications
You must be signed in to change notification settings - Fork 704
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
Cabal Error Refactor #9018
Cabal Error Refactor #9018
Conversation
…' calls and throws Error types as exception. CabalException will hold all ErrorTypes, types will be incrementally added per module. The VerboseException a will have CabalException and cabalInstallException variously in the a position Utils.hs 1. Creation of Error data types 2. Diewithexception and exceptionCode function 3. Instance for VerboseException Bench.hs and install.hs 1. Replaced die' call sites with dieWithException Right now I have only added errors from two modules Distribtuion/Simple/Bench and Distribution/Simple/Install. Error types will be added incrementally.
One immediate objection that comes to mind: let's not put more stuff in |
More generally, CI runs with Also, we format the code base with |
Yes I agree. It will be easy to refer to the exception types as well. |
I don't think the name or location matter all that much: we can always bike-sched it. I'd look what others do (e.g. Stack) or just go with Distribution.Simple.Errors. |
This is a good start. You'll eventually want a version of Also, I think the idea is that each type of exception gets its own constructor with its own code. So each individual BenchmarkException etc. should have a constructor eventually, rather than one catchall constructor which takes a string. Then there should be a function |
Thank you, I have created a function The new module On the idea of each type of exception having its own constructor, I have incorporated the same in the modules |
…' calls and throws Error types as exception. CabalException will hold all ErrorTypes, types will be incrementally added per module. The VerboseException a will have CabalException and cabalInstallException variously in the a position Utils.hs 1. Creation of Error data types 2. Diewithexception and exceptionCode function 3. Instance for VerboseException Bench.hs and install.hs 1. Replaced die' call sites with dieWithException Right now I have only added errors from two modules Distribtuion/Simple/Bench and Distribution/Simple/Install. Error types will be added incrementally.
5663f3b
to
9e6a92c
Compare
…abal into Cabal-Error-Refactor
This file is redundant.
This file is redundant.
One more thing: there's a "Manual QA process": https://github.com/haskell/cabal/blob/master/CONTRIBUTING.md#qa-notes It'd be best if in the original post in the PR under the heading "QA Notes" you put instructions on how to create a simple project that fails and prints a message with an error code. |
The "rip" changes look good, but note the new failures. Also I think you are printing callstacks at too low a verbosity -- note that there were no callstacks printed in these circumstances before. |
I see for all the test cases that are failed in this run, the marked verbose input is "-vverbose +markoutput +nowrap". I think the recent failures that popped up, happened after I replaced the die' call sites with new constructors in the |
I believe this is basically ready for review, and it would be good to rapidly review and merge so that other work can proceed along the same lines on top of this basic exception/reporting structure... |
@@ -192,7 +192,8 @@ getSourceFiles verbosity dirs modules = flip traverse modules $ \m -> | |||
findFileWithExtension ["hs", "lhs", "hsig", "lhsig"] dirs (ModuleName.toFilePath m) | |||
>>= maybe (notFound m) (return . normalise) | |||
where | |||
notFound module_ = die' verbosity $ "can't find source for module " ++ prettyShow module_ | |||
notFound module_ = | |||
dieWithException verbosity $ CantFindSoureModule module_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OOC, why is it spelled "Soure" instead of "Source"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a typo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dieWithException verbosity $ CantFindSoureModule module_ | |
dieWithException verbosity $ CantFindSourceModule module_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it was a typo, Thanks for pointing out. Changed to "CantFindSourceModule"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely packed first PR for an ambitious goal, thank you very much @SuganyaAK
Thank you
Thank you @Kleidukos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
@mergify refresh |
✅ Pull request refreshed |
Fixes #8618 #8543
This PR introduces three major changes
CabalException
for the Cabal package that has just enough constructors to cover a few modules I have committed as part of this PR, which will incrementally grow and a future idea of creatingCabalInstallException
for Cabal-Install Package.dieWithException
which will replacedie'
function and throws Exceptions.VerboseException
which will be polymorphic overCabalException
andCabalInstallException
I would appreciate your feedback, review comments and suggestions.
Please include the following checklist in your PR:
Bonus points for added automated tests!