It's easy to know when a cake is prepared and baked perfectly, because it comes out moist, with a smooth, even crumb and a delicate texture. Unfortunately there are a great many ways to fall short of that goal, and deducing what went wrong requires some understanding of how the recipe's ingredients and method relate to one another. For example, a common flaw in many cakes is large holes or elongated tunnels. There are a number of interrelated problems that can lead to this outcome.
Hot, Hot, Hot
Sometimes the root of your problem is as simple as a balky thermostat in your oven. If the oven is running hotter than it's supposed to, parts of the batter will heat more quickly than they should. The leavening in those areas makes the batter puff vigorously, then the cake sets and firms around those large air spaces. If your cake shows other symptoms of overbaking, such as a tough or overly-dark crust, that's probably what happened. You can check this by purchasing an inexpensive oven thermometer and using that to verify the accuracy of your oven's settings.
Much Too Much
A similar result can occur if you've simply used too much leavening, either because your recipe is flawed or because of an error in measuring. If you make the same recipe a second time and get the same result, you can probably assume it's a problem with the recipe. In most cases, your recipe should call for approximately a teaspoon of baking powder for every cup of flour. Baking soda is more powerful, requiring only 1/4 teaspoon. Reduce the amount of leavening to meet that rule of thumb, and it should correct the problem.
All Mixed Up
If it turns out that your oven is at the correct temperature and there are no glaring flaws in your recipe, it might come down to your mixing technique. If you haven't mixed your ingredients together adequately, large holes or tunnels can result either from a lump of unmixed fat melting away, or from too much leavening concentrated in one spot. If the cake also has a coarse and dense texture, that could be why. On the other hand, if you mix your batter for too long, you run the risk of developing strong strands of gluten. This traps too much gas from the leavening, creating large bubbles. Gluten also makes the cake chewy, a second symptom that can confirm your diagnosis.
Wrong Kind of Flour
Sometimes you can get too much gluten development even if you don't over-mix your batter. That's because some flours have much more gluten than others. If you ordinarily use all-purpose flour for your baking, try switching it out for pastry or cake flour the next time you bake from your troublesome recipe. Both varieties are much lower in gluten than all-purpose flour, and cake flour is specially formulated to mix quickly and thoroughly with other ingredients. If your oven temperature and mixing methods are correct, switching flours will usually fix the problem.