When client expect json, format the error message as JSON