You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When one is passing an object with circular dependencies from JS to Elm and then calls Json.Encode.encode on the Value you get a runtime Error from within Elm.
Of course the source of the error is from JS land but it would be nice if Elm gave a better Error message and log something like "<Json with circular references>" rather than a stack trace. Maybe the JSON.stringify call could be put in a try/catch or something. It's not a huge issue but I have encountered this error multiple times when people were printing stuff for debugging and it would be helpful if Elm told them the source of their error right away.
SSCCE:
-- ElmmoduleMainexposing (..)
importBrowserimportHtmlexposing (text)
importJson.EncodeasJEtype alias Model={}type Msg=NoOpinit:JE.Value-> ( Model, CmdMsg )
init flags =let _ =JE.encode 2 flags -- will cause an infinite recursionin({},Cmd.none )main:ProgramJE.ValueModelMsgmain =Browser.document
{ view =\_ ->{ title="SSCCE", body =[ text "this will crash"]}, init = init
, update =\msg model ->(model,Cmd.none), subscriptions = always Sub.none
}
// JSElm.Main.init({flags: window});
The text was updated successfully, but these errors were encountered:
When one is passing an object with circular dependencies from JS to Elm and then calls
Json.Encode.encode
on theValue
you get a runtime Error from within Elm.Of course the source of the error is from JS land but it would be nice if Elm gave a better Error message and log something like
"<Json with circular references>"
rather than a stack trace. Maybe theJSON.stringify
call could be put in a try/catch or something. It's not a huge issue but I have encountered this error multiple times when people were printing stuff for debugging and it would be helpful if Elm told them the source of their error right away.SSCCE:
The text was updated successfully, but these errors were encountered: