fixing API JSON error parsing handling