Pokemon Go has been known for being notorious about pounding the ban hammer. For one, if you leave high CP Pokemon in gyms, you are now one candidate for being banned when you are reported three times for 'cheating' and being suspicious with such a high CP creature, even though you honestly earned it. As of this writing, it is unclear if this issue has been resolved or not but the thing to remember is that Pokemon Go and player bans mostly go hand-in-hand.
Another case is that one time Belgium got banned due to an experiment by one person about a theory on IP bans. It turned out the country's main internet provider got detected and was blocked from accessing Pokemon Go servers affecting most if not all the players in the said country.
Perhaps the biggest complaint about 'unjust' bans is the time when paying players that were using jailbroken or rooted phones got banned from playing Pokemon Go. These angered affected Pokemon Go trainers and demanded refunds.
Today, there have been reports from several users that they are banned because of experiencing gym battle errors. Pokemon Go trainers explain that eveytime they go battle in a gym, their avatar would unintentionally wander off far away from the gym's location, disconnecting them from the battle.
Do not persist if you encounter gym errors
This is clearly a GPS accuracy glitch which Pokemon Go players have no control over. Nonetheless, some have already reported that every bunch of times they get this gym error, they also receive a temporary ban of at least 10 minutes. The soft ban can elevate to a permanent ban if you continue to battle in gyms and get disconnected anyway. So based on these statements, it is better to avoid getting the errors again and again, get a better internet signal instead.
What to do if you encounter a gym battle 'error'
First of all, stop persisting to battle. It simply means that your internet connection is not accurate enough to position you within a gym's range. What you need to do is get closer to the gym's location and get a better position within the gym's range.
Second, go to the 'settings' of your phone and make sure that your locating method for GPS include all three: GPS, WIFI, and Mobile Networks. With this, it is obvious that you must also turn on your GPS, WIFI (even if not used), and Mobile Data.
Third, make sure your mobile data or wifi connection is strong. Doing these steps will help better triangulate your location and will not let your avatar wander off by itself resulting to gym errors and ultimately to being banned. Below is an example of a gym battle error in Pokemon Go: