Hi,
ad If link A fails, traffic flow has to be throgh linkB and linkD)
This can be done by HSRP running between R1 and R2 on the LAN side with WAN line tracking
ad If linkC fails, traffic flow has to be throgh linkA and linkE)
You'd need an SVI L3 interface configured on R1 with C and E switched (L2) interfaces belonging to the VLAN assigned to the SVI.
C and E would be used by the LAN devices depending on their place in the L2 topology. One of them might be blocked by STP, in that case tuning STP might make E blocked as long as C is Up.
(And similar configuration on R2.) With HSRP running over the SVIs as mentioned above, this would work. As 1840s are offering integrated switch, this might be possible. (But I have never configured that personally.)
If linkC and linkE fails, traffic flow has to be throgh linkB and linkD)
Yes, the design proposed above would fulfil this, too.
HTH,
Milan