insert some try-except clauses into resource detection