Explicit test on token type to make sure we don't expose internal error