Error 21 is over/under current to the motor, which causes the controller to shut down.
Were you riding hard at a high level of PAS when the error first occurred?
Did you have a tip over incident or encounter brush while riding?
The first thing to do is make sure the bike is cool and fully charged. Then do a factory reset on the controller.
If the problem persists inspect your wiring to make sure all connectors are fully seated and the cables are not pinched or abraded.
I am sure Aventon support will have better and more detailed suggestions for you.
Please keep us posted.