Skip to content

Commit

Permalink
Move runtime errors to Native.Utils
Browse files Browse the repository at this point in the history
  • Loading branch information
process-bot committed Nov 5, 2014
1 parent 8eace70 commit 96f6750
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions compiler/Generate/JavaScript.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ internalImports name =
[ varDecl "_N" (obj ["Elm","Native"])
, include "_U" "Utils"
, include "_L" "List"
, include "_E" "Error"
, varDecl Help.localModuleName (string (Module.nameToString name))
]
where
Expand Down Expand Up @@ -150,7 +149,7 @@ expression (A region expr) =
(A _ (Var (Var.Canonical (Var.Module ["Basics"]) "otherwise")), _) ->
safeIfs branches'
(A _ (Literal (Boolean True)), _) -> safeIfs branches'
_ -> ifs branches' (throw "If" region)
_ -> ifs branches' (throw "badIf" region)
where
safeIfs branches = ifs (init branches) (snd (last branches))
ifs branches finally = foldr iff finally branches
Expand Down Expand Up @@ -230,7 +229,7 @@ definition (Canonical.Definition pattern expr@(A region _) _) = do

safeAssign = varDecl "$" (CondExpr () if' (ref "_raw") exception)
if' = InfixExpr () OpStrictEq (obj ["_raw","ctor"]) (string name)
exception = Help.throw "Case" region
exception = Help.throw "badCase" region

_ ->
do defs' <- concat <$> mapM toDef vars
Expand Down Expand Up @@ -262,7 +261,7 @@ match region mtch =
| otherwise = e

Case.Fail ->
return [ ExprStmt () (Help.throw "Case" region) ]
return [ ExprStmt () (Help.throw "badCase" region) ]

Case.Break -> return [BreakStmt () Nothing]

Expand Down
2 changes: 1 addition & 1 deletion compiler/Generate/JavaScript/Helpers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ localModuleName = "$moduleName"

throw :: String -> Region -> Expression ()
throw kind region =
obj ["_E",kind] `call` [ ref localModuleName, string (PP.renderPretty region) ]
obj ["_U",kind] `call` [ ref localModuleName, string (PP.renderPretty region) ]

-- Function Calls

Expand Down

0 comments on commit 96f6750

Please sign in to comment.