make sure we return a JSON mapping on errors