Which expression of condolence is more formal?

 - I am sorry to hear that your pet fish died.
 - I'm sorry your pet fish kicked the bucket.
The second expression of condolence is more formal. The other expression of condolence uses a contraction (I'm) and insensitive-sounding slang (kicked the bucket).