Catching null pointer in queries with wrong field

Use same format as below Exception (fieldname mentioned in the text).