Srimad Bhagavatam Canto 08, Chapter 03, Text 32

SB 8.3.32

so ’ntah-sarasy urubalena grhita arto
 drstva garutmati harim kha upatta-cakram
utksipya sambuja-karam giramaha krcchran
 narayanakhila-guro bhagavan namas te
 
Translation by His Divine Grace A. C. Bhaktivedanta Swami Srila Prabhupada: 
 
Gajendra had been forcefully captured by the crocodile in the water and was feeling acute pain, but when he saw that Narayana, wielding His disc, was coming in the sky on the back of Garuda, he immediately took a lotus flower in his trunk, and with great difficulty due to his painful condition, he uttered the following words: “O my Lord, Narayana, master of the universe, O Supreme Personality of Godhead, I offer my respectful obeisances unto You.”
 
Purport by His Divine Grace A. C. Bhaktivedanta Swami Srila Prabhupada: 
 
The King of the elephants was so very eager to see the Supreme Personality of Godhead that when he saw the Lord coming in the sky, with great pain and in a feeble voice he offered respect to the Lord. A devotee does not consider a dangerous position to be dangerous, for in such a dangerous position he can fervently pray to the Lord in great ecstasy. Thus a devotee regards danger as a good opportunity. Tat te ’nukampam susamiksamanah. When a devotee is in great danger, he sees that danger to be the great mercy of the Lord because it is an opportunity to think of the Lord very sincerely and with undiverted attention. Tat te ’nukampam susamiksamano bhuñjana evatma-krtam vipakam (Bhag. 10.14.8). He does not accuse the Supreme Personality of Godhead for having let His devotee fall into such a dangerous condition. Rather, he considers that dangerous condition to be due to his past misdeeds and takes it as an opportunity to pray to the Lord and offer thanks for having been given such an opportunity. When a devotee lives in this way, his salvation — his going back home, back to Godhead — is guaranteed. We can see this to be true from the example of Gajendra, who anxiously prayed to the Lord and thus received an immediate chance to return home, back to Godhead.
Srimad Bhagavatam Canto 08, Chapter 03, Text 31
Srimad Bhagavatam Canto 08, Chapter 03, Text 33