miku1958
(Miku1958)
1
I create Regex by a rather long regular expression, but it gives me the following error:
Printing description of error:
▿ expected '''
▿ error : expected '''
▿ diag : Diagnostic
- behavior : _RegexParser.Diagnostic.Behavior.error
- message : "expected \'\'\'"
▿ location : Location
▿ range : Range(Swift.String.Index(_rawBits: 1310983)..<Swift.String.Index(_rawBits: 1310983))
▿ lowerBound : Index
- _rawBits : 1310983
▿ upperBound : Index
- _rawBits : 1310983
▿ underlyingParseError : Optional<ParseError>
▿ some : expected '''
- expected : "\'"
▿ location : Location
▿ range : Range(Swift.String.Index(_rawBits: 1310983)..<Swift.String.Index(_rawBits: 1310983))
▿ lowerBound : Index
- _rawBits : 1310983
▿ upperBound : Index
- _rawBits : 1310983
And I'm trying to locate the location of the statement through this error, but I can't find how to create a specific Index with this _rawBits, and there's no way to get the location out of this error.
miku1958
(Miku1958)
2
Ok I retrieve it through the Mirror:
let location = Mirror(reflecting: error).children.first { (label, value) in label == "location" }!.value
let range = Mirror(reflecting: location).children.first { (label, value) in label == "range" }!.value as! Range<String.Index>