davidsantiago/hickory — pull request #5 by Raynes (2013-01-22 18:36:56+00:00)
Title: Added some error handling

This is the first thing I came up with. I've been using it locally for a while and it works well for me.

In summary, it catches the blank "No matching clause: " exception and throws an ex-info exception that contains the 'dom'. The message of this exception is "Not a valid node: ". The only part I'm not really sure about is how I remove the `:content` key from the `dom` arg if it is a map. If `dom` is a map and that no matching clause exception occurred, it's going to be because the `:type` key was missing or incorrect. In those cases, it'd try to print the whole map which would be that part of the tree all the way down, which could potentially mean printing a huuuuuuge piece of HTML in an error message. Not sure if you care about that, but it seemed like the right thing to do.

If this isn't what you're looking for at all, that's fine too! If that's the case, I can revamp it with any ideas you might have.