error handling added to rest api