update error handling and send error response message

update error handling and send error response message