When a person does something in good faith and stumbles upon some obstacle, let him trust that Hashem will save him.
Hashem arranged the obstacle for him so that he would pave a trodden path for his children through this very obstacle, that they may be saved from it.
Sefer HaMidos, Trust in God, Part II §1