         let caps = result.rawCaptures.slices(from: input)
         return (input[result.range], caps)
       } else if start == input.endIndex {
-        throw "match not found for \(regex) in \(input)"
+        throw MatchError("match not found for \(regex) in \(input)")
       } else {
         input.formIndex(after: &start)
       }

import XCTest
@testable import _MatchingEngine
@testable import _StringProcessing

extension Executor {
  func _firstMatch(

        if expect == nil {
          continue
        } else {
          throw MatchError("Match failed")
        }
      }
      guard let expect = expect else {
        throw MatchError("""
            Match of \(test) succeeded where failure expected in \(regex)
            """)
      }
      let capStrs = caps.map { $0 == nil ? nil : String($0!) }
      guard expect.count == capStrs.count else {
        throw MatchError("""
          Capture count mismatch:
            \(expect)
            \(capStrs)
          """)
      }

      guard expect.elementsEqual(capStrs) else {
        throw MatchError("""
          Capture mismatch:
            \(expect)
            \(capStrs)
          """)
      }
    } catch {
      if !xfail {
