Refactor out error case & apply suggestions.
Refactor out error case & apply suggestions.

This is almost entirely refactoring and message changing, with the
single behavioral change of panicking for unexpected output.

graydon/rust,graydon/rust,aidancully/rust,graydon/rust,aidancully/rust,aidancully/rust,graydon/rust,graydon/rust,graydon/rust,aidancully/rust,aidancully/rust,aidancully/rust