Test that invalid error code raises the right exception.
Test for catching invalid tokens.
Also check that invalid states raise an assertion error.