handle error on allocation failed