fix issue#8176

Ignore null matches when creating JSON Error object