Use an if-else chain and an assert in do_alignment instead of a switch with a default that throws.