That is a very good question. The majority of opening books teach you how to play against good moves, not bad ones.
One thing you can try, is to plug the position (including the deviation) into an engine, that way you will probably find tactical refutations if they exist. [edit:after the game is over, of course! :)]
If the deviation is more of a positional or strategic mistake, it is much more difficult without a good understanding of the idea behind the opening.
As a low level chess player, the majority of my games break from the opening book lines very quickly. So seeing as how black's moves in the openings are considered "best" for a particular line, what happens when a weak opponent plays a non book move? Theoretically white should be better, correct?
My problem is when this happens, I have no idea how to exploit this weakness. I know that most opening theory is based on the idea that your opposition is going to play optimal moves and at a certain point you come to a position where now white or black will have a good goal or plan. So if black breaks the book moves early, how does white continue?
Obviously a high rated player could handle the situation easily and come out of the opening with the advantage, but as a weak class player who follows the "don't study opening theory until you reach expert" rule (though I do look at opening lines just to have something to play), I usually am not able to come out better than equal.