fix circular struct error handling

otherwise JSON.stringify errors would crash the host