error handling from server,reduce code