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

Also output proper ProgrammingError() if unexpected enum value is seen.
Merge pull request #761 from jimis/bug2980

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