Skip to content

Commit

Permalink
Error reporting fixes. finos#33
Browse files Browse the repository at this point in the history
  • Loading branch information
AttilaMihaly committed Dec 2, 2020
1 parent 24cefa6 commit bdf7785
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 29 deletions.
2 changes: 1 addition & 1 deletion cli/src/Morphir/Elm/CLI.elm
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ decodeError =
|> Decode.map FrontendError

"type_error" ->
Decode.index 1 (Decode.succeed [])
Decode.index 1 (Decode.list decodeValueTypeError)
|> Decode.map TypeError

other ->
Expand Down
61 changes: 33 additions & 28 deletions src/Morphir/Type/Infer/Codec.elm
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@ decodeValueTypeError : Decode.Decoder ValueTypeError
decodeValueTypeError =
Decode.map2 ValueTypeError
(Decode.index 1 decodeName)
-- TODO: implement
(Decode.succeed (TypeErrors []))



-- TODO: implement


encodeTypeError : TypeError -> Encode.Value
encodeTypeError typeError =
case typeError of
Expand All @@ -47,30 +44,10 @@ encodeTypeError typeError =
]

LookupError lookupError ->
case lookupError of
CouldNotFindConstructor fQName ->
Encode.list identity
[ Encode.string "could_not_find_constructor"
, encodeFQName fQName
]

CouldNotFindValue fQName ->
Encode.list identity
[ Encode.string "could_not_find_value"
, encodeFQName fQName
]

CouldNotFindAlias fQName ->
Encode.list identity
[ Encode.string "could_not_find_alias"
, encodeFQName fQName
]

ExpectedAlias fQName ->
Encode.list identity
[ Encode.string "expected_alias"
, encodeFQName fQName
]
Encode.list identity
[ Encode.string "lookup_error"
, encodeLookupError lookupError
]

UnknownError message ->
Encode.list identity
Expand All @@ -87,6 +64,34 @@ encodeTypeError typeError =
]


encodeLookupError : LookupError -> Encode.Value
encodeLookupError lookupError =
case lookupError of
CouldNotFindConstructor fQName ->
Encode.list identity
[ Encode.string "could_not_find_constructor"
, encodeFQName fQName
]

CouldNotFindValue fQName ->
Encode.list identity
[ Encode.string "could_not_find_value"
, encodeFQName fQName
]

CouldNotFindAlias fQName ->
Encode.list identity
[ Encode.string "could_not_find_alias"
, encodeFQName fQName
]

ExpectedAlias fQName ->
Encode.list identity
[ Encode.string "expected_alias"
, encodeFQName fQName
]


encodeUnificationError : UnificationError -> Encode.Value
encodeUnificationError unificationError =
case unificationError of
Expand Down

0 comments on commit bdf7785

Please sign in to comment.