In one of our chess games at work I learnt that you cannot perform the castle move with King if the blocks where the king has to pass through or end at are under threat from any of opponentโ€™s piece(s).

Examples

Midway block threatened by queen We cannot castle in this case because one of the midway blocks is threatened by black queen.

End block threatened by rook We cannot castle in this case because the square where king would end up is threatened by black rook.