You will not be able to do that as Elm has its own scheduler that uses 
`setTimeout(0, ...)` to do the event loops, including the very first init, 
and that errors causes that event loop to die.  I'd probably recommend 
changing your flags to handle this case differently or you might be able to 
do it by setting up a port and messaging into it and maybe seeing if the 
port exists (if it does not exist it all then the app may not have loaded, 
I've not tested this to see 'when' the ports are setup in the setup but you 
could always have the program message back 'out' if it was successful, 
though I'd go with changing how the data is passed in).

On Saturday, October 15, 2016 at 11:20:11 AM UTC-6, Kevin Berridge wrote:
> I'm using App.programWithFlags to initialize the state of my model from 
> local storage (as described in this blog article 
> <>).
>  But when the schema of my model changes (ex: I added a new field to a 
> record type) it will correctly error out when Elm.Main.fullscreen is called 
> with error: "You are trying to initialize module `Main` with an unexpected 
> argument."
> I am OK with throwing away the state from local storage and starting from 
> scratch when this happens, so I tried to add a try catch in the JavaScript 
> but surprisingly (to me) the catch doesn't fire.
> try {
>     elmApp = Elm.Main.fullscreen(startingState);
> }
> catch (e) {
>     elmApp = Elm.Main.fullscreen(null); // this never gets called
> }
> Is there a way that I can catch this error?  Or do I need to use a 
> different approach?
> Thanks,
> Kevin

You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
For more options, visit

Reply via email to