<commit_before>import Nimble
import RxSwift
import RxTest

/// A Nimble matcher that succeeds when the actual events emit an error
/// of any type.
public func throwError<T: Equatable>() -> Predicate<RecordedEvents<T>> {
    func extractError(_ recorded: RecordedEvents<T>?) -> [Error]? {
        func extractError<E>(_ recorded: Recorded<Event<E>>) -> Error? {
            return recorded.value.error
        }

        #if swift(>=4.1)
        return recorded?.compactMap(extractError)
        #else
        return recorded?.flatMap(extractError)
        #endif
    }


    return Predicate { actualEvents in
        var actualError: Error?
        do {
            let recordedEvents = try actualEvents.evaluate()
            if let error = extractError(recordedEvents)?.first {
                throw error
            }
        } catch {
            actualError = error
        }

        if let actualError = actualError {
            return PredicateResult(bool: true, message: .expectedCustomValueTo("throw any error", "<\(actualError)>"))
        } else {
            return PredicateResult(bool: false, message: .expectedCustomValueTo("throw any error", "no error"))
        }
    }
}<commit_msg>Fix breaking changes introduced in Nimble 9<commit_after>import Nimble
import RxSwift
import RxTest

/// A Nimble matcher that succeeds when the actual events emit an error
/// of any type.
public func throwError<T: Equatable>() -> Predicate<RecordedEvents<T>> {
    func extractError(_ recorded: RecordedEvents<T>?) -> [Error]? {
        func extractError<E>(_ recorded: Recorded<Event<E>>) -> Error? {
            return recorded.value.error
        }

        #if swift(>=4.1)
        return recorded?.compactMap(extractError)
        #else
        return recorded?.flatMap(extractError)
        #endif
    }


    return Predicate { actualEvents in
        var actualError: Error?
        do {
            let recordedEvents = try actualEvents.evaluate()
            if let error = extractError(recordedEvents)?.first {
                throw error
            }
        } catch {
            actualError = error
        }

        if let actualError = actualError {
            return PredicateResult(bool: true, message: .expectedCustomValueTo("throw any error", actual: "<\(actualError)>"))
        } else {
            return PredicateResult(bool: false, message: .expectedCustomValueTo("throw any error", actual: "no error"))
        }
    }
}
{'fraction_non_alphanumeric': 0.10179153094462541, 'fraction_numerical': 0.002035830618892508, 'mean_word_length': 2.297986577181208, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '113164', 'n_tokens_mistral': 666, 'n_tokens_neox': 634, 'n_words': 186}