itod/pegkit

Error reporting request

drekka opened this issue · 0 comments

Hi. I'm parsing a simple string that looks like this:

[Abc]

This parses fine, but when the app checks 'Abc', it's not valid so I'm raising an error by using the [parser raise:@"..."]; statement.

At the moment I get an error which when dumped to the logs, looks like this:

Error Domain=PEGKitErrorDomain Code=1 "Failed to match next input token" UserInfo=0x7f9a7b710710 {NSLocalizedDescription=Failed to match next input token, range=NSRange: {9223372036854775807, 5}, lineNumber=Unknown, NSLocalizedFailureReason=Unable to find any runtime object called Abc
Line : Unknown
}

My error message seems to only be accessible through the localizedFailureReason and wrapped with line feeds. IN my case I want to do other things with it.

I'd like to have the peg kit actually put my error message as the description. I'm also not sure what the range is meant to represent as any time I see an error, it always seems to be x,5. With neither the 5 or the 5 having anything to do with the location of error as far as I can tell.

Can this be improved?