Send error as JSON on 502