The hostile creature’s movement doesn't provoke an opportunity attack from you, so your War Caster feat isn't triggered.
The War Caster feat (PHB 170) says:
When a hostile creature’s movement provokes an opportunity attack from
you, you can use your reaction to cast a spell at the creature, rather
than making an opportunity attack. The spell must have a casting time
of 1 action and must target only that creature.
The hostile creature’s movement doesn't provoke an opportunity attack from you, so your War Caster feat isn't triggered.
The Dimension Door spell description (PHB 233) says:
You teleport yourself from your current location to any other spot
within range. You arrive at exactly the spot desired. It can be a
place you can see, one you can visualize, or one you can describe by
stating distance and direction, such as "200 feet straight downward"
or "upward to the northwest at a 45- degree angle, 300 feet."
Dimension Door is a teleportation spell, and teleportation doesn't trigger opportunity attacks.
The rules on opportunity attacks (PHB 195) state:
You also don't provoke an opportunity attack when you teleport or when
someone or something moves you without using your movement, action, or
reaction.
Additionally, spells do what they say they do, and the spell description of Dimension Door does not say it creates a door that you need to pass through; it merely teleports you to the spot within range, so the proposed mechanism to prevent the teleportation from occurring wouldn't work, either.
Thank you to nick012000 for contributing the additional note.