Implements error handling on invalid file types.