|The stupid question is the question not asked|
You could use file(1) magic to check if a file is indeed a compressed file before trying to uncompress.
... but you should remember that this creates a TOCTTOU vulnerability. Also, magic checks check only for magic numbers, not for validity.
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
In reply to Re^2: How do you get IO::Uncompress::Gunzip to error if the input file isn't a GZ file?