Improving api error logging