Is mercy used to mean the same thing in the next two sentences?

It was a mercy that we were not inside when the roof collapsed.

He threw himself on the mercy of the court.
different meanings