on master help sign in
Add newlines in "missing patterns" error message
commit8f6ebdda0f460e68d4f58e934a4b1e03ccdc4f07 authorEvan Czaplicki <info@elm-lang.org> dateWed 9 Sep 2015, 12:54 (11 years ago) parent97572f9
1 file changed+25−18
src/Reporting/Error/Pattern.hs+25−18
src/Reporting/Error/Pattern.hs+25−18
@@ -31,24 +31,7 @@ toReport dealiaser err =
3131 ( "The following patterns are not being handled:\n"
3232 ++ viewPatternList unhandled
3333 ++ "\n\n"
34− ++ "Did you add a new tag to a union type? Add how it should be handled here and"
35− ++ "you will be all set!"
36− ++ ""
37− ++ "If you want to go quick and implement this later, you can end the pattern with:"
38− ++ ""
39− ++ " _ ->"
40− ++ " Debug.crash \"TODO\""
41− ++ ""
42− ++ "When I see cases that end with this pattern, I augment the runtime error with"
43− ++ "the module name, the relevant line numbers, and the value led down that branch."
44− ++ ""
45− ++ "That said, you almost never want this in production code. If you think there"
46− ++ "are certain cases that are impossible in practice, consider refining how you"
47− ++ "model the data. If it can never happen in practice, you can probably define a"
48− ++ "union type such that the \"impossible\" cannot even be constructed in the"
49− ++ "first place. That is how you make something \"impossible\" truly impossible."
50− ++ ""
51− ++ "I won't say \"I told you so\" in the runtime error, but I'll be thinking it ;)"
34+ ++ incompleteExplanation
5235 )
5336
5437 Redundant ->
@@ -67,3 +50,27 @@ viewPatternList unhandledPatterns =
6750 concatMap ((++) "\n ") $
6851 map Pattern.toString showPatterns
6952 ++ if null rest then [] else ["..."]
53+
54+
55+incompleteExplanation :: String
56+incompleteExplanation =
57+ unlines
58+ [ "Did you add a new tag to a union type? Add how it should be handled here and"
59+ , "you will be all set!"
60+ , ""
61+ , "If you want to go quick and implement this later, you can end the pattern with:"
62+ , ""
63+ , " _ ->"
64+ , " Debug.crash \"TODO\""
65+ , ""
66+ , "When I see cases that end with this pattern, I augment the runtime error with"
67+ , "the module name, the relevant line numbers, and the value led down that branch."
68+ , ""
69+ , "That said, you almost never want this in production code. If you think there"
70+ , "are certain cases that are impossible in practice, consider refining how you"
71+ , "model the data. If it can never happen in practice, you can probably define a"
72+ , "union type such that the \"impossible\" cannot even be constructed in the"
73+ , "first place. That is how you make something \"impossible\" truly impossible."
74+ , ""
75+ , "I won't say \"I told you so\" in the runtime error, but I'll be thinking it ;)"
76+ ]