def _fail_if_response_code_is_invalid(self, response_code):
        if response_code is not None and not isinstance(response_code, int):
            e_msg = 'Invalid response code.'
            hint = 'A response code must be either an integer, or a valid string.'
            valid_strings = set()
            for code_name in dir(http):
                code = getattr(http, code_name, Ellipsis)
                if isinstance(code, int) and code in http.RESPONSES:
                    valid_strings.add('"%s"' % code_name)

            detail = 'Valid strings are: %s.' % (','.join(valid_strings))
            raise exceptions.ConfigurationError(e_msg, hint, detail)
dataset/ETHPy150Open foundit/Piped/piped/processors/web_processors.py/ResponseWriter._fail_if_response_code_is_invalid/original