catch exception in map reduce function