Skip to content

Commit 7daad6b

Browse files
authored
Merge pull request #6300 from commercialhaskell/stan-2
Clear a STAN suggestion.
2 parents 87c1a5b + 5c77029 commit 7daad6b

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

doc/maintainers/stack_errors.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
In connection with considering Stack's support of the
66
[Haskell Error Index](https://errors.haskell.org/) initiative, this page seeks
77
to take stock of the errors that Stack itself can raise, by reference to the
8-
`master` branch of the Stack repository. Last updated: 2023-10-16.
8+
`master` branch of the Stack repository. Last updated: 2023-10-17.
99

1010
* `GHC.GHC.Utils.GhcPkg.Main.Compat`
1111

@@ -131,6 +131,7 @@ to take stock of the errors that Stack itself can raise, by reference to the
131131
~~~haskell
132132
[S-8251] = PackageIdNotFoundBug String
133133
[S-2483] | ExecutableToRunNotFound
134+
[S-8600] | NoPackageIdReportedBug
134135
~~~
135136

136137
- `Stack.GhcPkg`

src/Stack/Exec.hs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import qualified Data.List as L
1515
import qualified Data.Map.Strict as Map
1616
import qualified Data.Set as Set
1717
import qualified Data.Text as T
18+
import RIO.NonEmpty ( head, nonEmpty )
1819
import RIO.Process ( exec )
1920
import Stack.Build ( build )
2021
import Stack.Build.Target ( NeedTargets (..) )
@@ -56,17 +57,21 @@ instance Exception ExecException where
5657
data ExecPrettyException
5758
= PackageIdNotFoundBug !String
5859
| ExecutableToRunNotFound
60+
| NoPackageIdReportedBug
5961
deriving (Show, Typeable)
6062

6163
instance Pretty ExecPrettyException where
6264
pretty (PackageIdNotFoundBug name) = bugPrettyReport "[S-8251]" $
63-
"Could not find the package id of the package" <+>
64-
style Target (fromString name)
65-
<> "."
65+
fillSep
66+
[ flow "Could not find the package id of the package"
67+
, style Target (fromString name) <> "."
68+
]
6669
pretty ExecutableToRunNotFound =
6770
"[S-2483]"
6871
<> line
6972
<> flow "No executables found."
73+
pretty NoPackageIdReportedBug = bugPrettyReport "S-8600" $
74+
flow "execCmd: findGhcPkgField returned Just \"\"."
7075

7176
instance Exception ExecPrettyException
7277

@@ -128,7 +133,10 @@ execCmd ExecOpts {..} =
128133
pkg <- getGhcPkgExe
129134
mId <- findGhcPkgField pkg [] name "id"
130135
case mId of
131-
Just i -> pure (L.head $ words (T.unpack i))
136+
Just i -> maybe
137+
(prettyThrowIO NoPackageIdReportedBug)
138+
(pure . head)
139+
(nonEmpty $ words $ T.unpack i)
132140
-- should never happen as we have already installed the packages
133141
_ -> prettyThrowIO (PackageIdNotFoundBug name)
134142

0 commit comments

Comments
 (0)