send error messages as JSON