Make the with-error type more explicit

This commit is contained in:
Tessa Kelly 2021-11-11 13:48:32 -08:00
parent a60f4587d5
commit d7ab8c1329

View File

@ -16,7 +16,8 @@ module InputErrorAndGuidanceInternal exposing
{-| -} {-| -}
type ErrorState type ErrorState
= NoError = NoError
| Error { message : Maybe String } | Error
| ErrorWithMessage String
{-| -} {-| -}
@ -31,7 +32,7 @@ setErrorIf isInError_ config =
{ config { config
| error = | error =
if isInError_ then if isInError_ then
Error { message = Nothing } Error
else else
NoError NoError
@ -48,7 +49,7 @@ setErrorMessage maybeMessage config =
NoError NoError
Just message -> Just message ->
Error { message = Just message } ErrorWithMessage message
} }
@ -76,7 +77,10 @@ getIsInError error =
NoError -> NoError ->
False False
Error _ -> Error ->
True
ErrorWithMessage _ ->
True True
@ -87,5 +91,8 @@ getErrorMessage error =
NoError -> NoError ->
Nothing Nothing
Error { message } -> Error ->
message Nothing
ErrorWithMessage message ->
Just message