handle possible exceptions while sending to client