evancz/Elm — pull request #320 by jsl (2013-11-04 02:00:18+00:00)
Title: Give more helpful error messages when deserializing elmi files

Provides an error message indicating incorrect compiler version or corrupt `elmi` file. Exit status will be 1 in either failure case and error message is printed to stderr. Uses the same validations against interfaces.data as well as standard .elmi files.

The following will be displayed when an elmi file has a different compiler version than the elm compiler that tries to load it:

$ elm Pong.elm
Found build artifacts created by a different Elm compiler version. Please rebuilt cache/Pong.elmi and try again.

The following will be displayed when a file that cannot be deserialized is encountered:

$ elm Pong.elm
Got an error, 'demandInput: not enough bytes' at offset 10303 of cache/Pong.elmi.

This error may be due to an outdated or corrupt artifact from a previous build. Please rebuild cache/Pong.elmi and try again.

I benchmarked this change against the current `dev` branch with 100 builds of Pong, and there didn't seem to be any significant difference in build time (10.134s for this branch versus 10.385s for dev, this branch was marginally faster than dev for some reason).