def METHOD_NAME(self, url: str, fail_on_error: bool):
    try:
        # A nosec comment is appended to the following line in order to disable the B310 check.
        # The urlopen argument is properly validated
        # [B310:blacklist] Audit url open for permitted schemes.
        with urlopen(url):  # nosec B310 nosemgrep
            pass
    except HTTPError as e:
        self._add_failure(
            f"The url '{url}' causes HTTPError, the error code is '{e.code}',"
            f" the error reason is '{e.reason}'.",
            FailureLevel.ERROR if fail_on_error else FailureLevel.WARNING,
        )
    except URLError as e:
        self._add_failure(
            f"The url '{url}' causes URLError, the error reason is '{e.reason}'.",
            FailureLevel.ERROR if fail_on_error else FailureLevel.WARNING,
        )
    except ValueError:
        self._add_failure(
            f"The value '{url}' is not a valid URL.",
            FailureLevel.ERROR,
        )