Only use drop object if data is compatible

How do I prevent my app from crashing and detect incompatible data before the data is used. I know you can wrap it with a try catch statement but other bits of code get into problems. Is there way that you can prevent the code from executing if there is a NilObjectException caught. In case you need to know by drop object data, I mean the ‘obj as DragItem’ parameter in the drop object event.

Thanks.