main: catch a few unhandled errors

If any of this initialization fails, something very bad has happened,
and we should not continue as-is (this has previously manifested in
strange bugs)
Merge pull request #1466 from jonboulle/errors

main: catch a few unhandled errors