Idioms to express relief/gratitude
One of my (Taiwanese) students asked me if there was an idiom to express mixed feelings of gratitude and relief when talking about something good having come out of something bad. The example she gave was missing a train and then later finding out the train had crashed.
I could only think of 'thanking your lucky stars' but I'm sure there must be something more appropriate. Any help would be appreciated, thanks!