Fix compiler warning (enum value not handled in switch).

Also output proper ProgrammingError() if unexpected enum value is seen. Thanks @awsiv for pointing this out.