on master help sign in
Get rid of a bunch of TODOs in error messages
commit04c5e28c03f49ee39f9a0386048ee81fcae00c42 authorEvan Czaplicki <info@elm-lang.org> dateTue 26 Apr 2016, 14:23 (11 years ago) parentec69a6c
4 files changed+28−8
src/Canonicalize/Effects.hs+1−1 src/Reporting/Error/Canonicalize.hs+19 src/Reporting/Error/Syntax.hs+2−2 src/Reporting/Error/Type.hs+6−5
src/Canonicalize/Effects.hs+1−1
@@ -73,7 +73,7 @@ figureOutKind region name rootType =
7373 <* checkPortType (makeError region name) incomingType
7474
7575 _ ->
76− Result.throw region (error "TODO - bad overall type")
76+ Result.throw region (Error.BadPort name rootType)
7777
7878
7979makeError :: R.Region -> String -> T.Canonical -> Maybe String -> A.Located Error.Error
src/Reporting/Error/Canonicalize.hs+19
@@ -23,6 +23,7 @@ data Error
2323 | Export String [String]
2424 | DuplicateExport String
2525 | Port PortError
26+ | BadPort String Type.Canonical
2627
2728
2829
@@ -242,6 +243,21 @@ toReport localizer err =
242243 ]
243244 )
244245
246+ BadPort name tipe ->
247+ Report.report
248+ "PORT ERROR"
249+ Nothing
250+ ("Port `" ++ name ++ "` has an invalid type."
251+ )
252+ ( Help.stack
253+ [ text ("You are saying it should be:")
254+ , indent 4 (RenderType.toDoc localizer tipe)
255+ , Help.reflowParagraph $
256+ "But you need to use the particular format described here:\
257+ \ <http://guide.elm-lang.org/effect_managers/>"
258+ ]
259+ )
260+
245261
246262argMismatchReport :: String -> Var.Canonical -> Int -> Int -> Report.Report
247263argMismatchReport kind var expected actual =
@@ -288,6 +304,9 @@ extractSuggestions err =
288304 Port _ ->
289305 Nothing
290306
307+ BadPort _ _ ->
308+ Nothing
309+
291310
292311unsafePromote :: Type.Raw -> Type.Canonical
293312unsafePromote (A.A _ rawType) =
src/Reporting/Error/Syntax.hs+2−2
@@ -135,7 +135,7 @@ toReport _localizer err =
135135 "If you just wanted a normal module, change the keywords `effect module`\
136136 \ to `module` and you should be all set. If you want a proper effect module,\
137137 \ you need to specify your commands and/or subscriptions. Read more about this\
138− \ here: <TODO> (please forgive me if I forgot to fill this in!)"
138+ \ here: <http://guide.elm-lang.org/effect_managers/>"
139139 )
140140
141141 MissingManagerOnEffectModule name ->
@@ -147,7 +147,7 @@ toReport _localizer err =
147147 "There is a small set of top-level functions and values that must be defined\
148148 \ in any complete effect module. The best thing is probably to just read more\
149149 \ about effect modules here:\
150− \ <TODO> (please forgive me if I forgot to fill this in!)"
150+ \ <http://guide.elm-lang.org/effect_managers/>"
151151 )
152152
153153 UnexpectedPort name ->
src/Reporting/Error/Type.hs+6−5
@@ -458,7 +458,8 @@ mismatchToReport localizer (MismatchInfo hint leftType rightType maybeReason) =
458458 ( cmpHint
459459 ("Your `" ++ name ++ "` function has this type:")
460460 "But it needs to have a type like this:"
461− [ "TODO - link to overview of effect managers"
461+ [ "You can read more about setting up effect managers properly here:\
462+ \ <http://guide.elm-lang.org/effect_managers/>"
462463 ]
463464 )
464465
@@ -471,8 +472,8 @@ mismatchToReport localizer (MismatchInfo hint leftType rightType maybeReason) =
471472 ( cmpHint
472473 "The state created by `init` has this type:"
473474 ("But `" ++ name ++ "` expects state of this type:")
474− [ "Make the two state types match and you should be all set!"
475− , "TODO - link to overview of effect managers"
475+ [ "Make the two state types match and you should be all set! More info here:\
476+ \ <http://guide.elm-lang.org/effect_managers/>"
476477 ]
477478 )
478479
@@ -483,8 +484,8 @@ mismatchToReport localizer (MismatchInfo hint leftType rightType maybeReason) =
483484 ( cmpHint
484485 "The `onEffects` function can send this type of message:"
485486 "But the `onSelfMsg` function receives this type:"
486− [ "Make the two message types match and you should be all set!"
487− , "TODO - link to overview of effect managers"
487+ [ "Make the two message types match and you should be all set! More info here:\
488+ \ <http://guide.elm-lang.org/effect_managers/>"
488489 ]
489490 )
490491