A sudden stop does not automatically excuse following too closely. The reason for the stop, traffic, visibility and any abrupt lane change matter. Record the sequence and look for independent witnesses or video.
What if the car in front of me stopped suddenly?
Read more: Rear-end collisions