using errorhandler to handle error.