Hei John, 

Nice to see you're working on that part again!

> I was wondering if such a patch would make sense:
> 
>  
> https://github.com/jmettraux/parslet/commit/d01ed604d158498635924ed1063f7fc27837ce81
> 
> […]
> which would match nicely with the #deepest(given) returning the deepest_cause
> instead of the given cause.

I've taken a quick peek at what you propose. If I understand you right, you'd 
like the deepest single error without its lineage. 

I've tried to conserve that exact lineage with my code. The logic was that it 
is easy to extend Cause with a method that extracts the deepest single error 
from that, but the inverse cannot be done. 

I would certainly accept a nicely written 'deepest_child' method on Cause as a 
patch! And a delegate on the exception maybe? Your code would look like this: 

begin
  parser.parse(s)
rescue Parslet::ParseFailed => ex
  puts ex.deepest_cause
  # or
  puts ex.cause.deepest_child
end

I feel having this as an option opens up the possibilities for others, instead 
of giving them just what we think they need. It encourages experimentation, if 
you so will. 

Or .. you can always convince me of your initial patch, you're the inventor of 
the method ;)

kaspar

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to