[Hackage] #510: Don't call exitWithFailure on parse error, instead return error or throw exception

#510: Don't call exitWithFailure on parse error, instead return error or throw exception ----------------------------+----------------------------------------------- Reporter: guest | Owner: Type: enhancement | Status: new Priority: normal | Milestone: Component: Cabal library | Version: 1.6.0.1 Severity: minor | Keywords: Difficulty: unknown | Ghcversion: Platform: | ----------------------------+----------------------------------------------- Please consider modifying ''readPackageDescription'' so that it doesn't end up calling ''dieWithLocation''. It seems the decision of what to do when a parse error occurs is better made in the application rather than the library. -- Ticket URL: http://hackage.haskell.org/trac/hackage/ticket/510 Hackage http://haskell.org/cabal/ Hackage: Cabal and related projects

#510: Don't call exitWith on parse error, instead return error or throw exception ----------------------------+----------------------------------------------- Reporter: guest | Owner: Type: enhancement | Status: new Priority: normal | Milestone: Component: Cabal library | Version: 1.6.0.1 Severity: minor | Resolution: Keywords: | Difficulty: unknown Ghcversion: | Platform: ----------------------------+----------------------------------------------- Changes (by guest): * summary: Don't call exitWithFailure on parse error, instead return error or throw exception => Don't call exitWith on parse error, instead return error or throw exception -- Ticket URL: http://hackage.haskell.org/trac/hackage/ticket/510#comment:1 Hackage http://haskell.org/cabal/ Hackage: Cabal and related projects

#510: Don't call exitWith on parse error, instead return error or throw exception ----------------------------+----------------------------------------------- Reporter: guest | Owner: Type: enhancement | Status: closed Priority: normal | Milestone: Component: Cabal library | Version: 1.6.0.1 Severity: minor | Resolution: invalid Keywords: | Difficulty: unknown Ghcversion: | Platform: ----------------------------+----------------------------------------------- Changes (by duncan): * status: new => closed * resolution: => invalid Comment: If you want to handle the parse errors you can use: {{{ parsePackageDescription :: String -> ParseResult GenericPackageDescription }}} The `ParseResult` gives you everything about the parsing outcome. It includes a structured description of any parse error or warnings. There are functions provided to format these errors and warnings into strings if you don't want to handle them individually. By contrast, `readPackageDescription` is an "all in one" convenience function that works in IO, reads the file and throws exceptions in IO if reading the file or parsing it fails. {{{ readPackageDescription :: Verbosity -> FilePath -> IO GenericPackageDescription }}} Admitedly, it does use the wrong exception if parsing fails, it uses the `ExitWith` exception where it should use `UserError`. It is still catchable however. But you clearly don't want to be using exceptions here, you want to use the pure function `parsePackageDescription` that gives you the chance to handle parse errors yourself. I'm closing this ticket but opening a new one about the issue with `die` throwing the wrong kind of exception. -- Ticket URL: http://hackage.haskell.org/trac/hackage/ticket/510#comment:2 Hackage http://haskell.org/cabal/ Hackage: Cabal and related projects

#510: Don't call exitWith on parse error, instead return error or throw exception ----------------------------+----------------------------------------------- Reporter: guest | Owner: Type: enhancement | Status: closed Priority: normal | Milestone: Component: Cabal library | Version: 1.6.0.1 Severity: minor | Resolution: invalid Keywords: | Difficulty: unknown Ghcversion: | Platform: ----------------------------+----------------------------------------------- Comment (by duncan): Oops, should have linked to the new ticket about `die`: #512. -- Ticket URL: http://hackage.haskell.org/trac/hackage/ticket/510#comment:3 Hackage http://haskell.org/cabal/ Hackage: Cabal and related projects
participants (1)
-
Hackage