develop  error handling code

develop  error handling