convert api errors into exceptions