lizzie icon indicating copy to clipboard operation
lizzie copied to clipboard

Exception Handling Question

Open du8die opened this issue 4 years ago • 2 comments

Hello,

I realize this project is essentially dead (shame, but I get it). So far, it's a game changer for me - so I'm looking forward to seeing all the possibilities.

One issue I'm having right now. If I have a JSON object, and I'm expecting that object to have a property, say "foo", all is well. get(v,'foo') returns the value just fine. However, if the property is missing, an exception is thrown. No problem.

However, I haven't seen in your documentation any way to handle exceptions.

So - how do I handle this error (because in this case, it's expected that some elements may not be available).

Thanks!

du8die avatar Mar 09 '22 18:03 du8die

Hi, there's no real exception support in Lizzie unfortunately, unless you're catching them in your C# code though. Not really sure how to intelligently accomplish that at the moment either. I'm currently spending all my time one magic (which BTW has exception handling, but also is a 100 times "larger" in scope than Lizzie) ...

polterguy avatar Mar 09 '22 21:03 polterguy

Just thought about it, and it would probably be easy to implement "try_get" as some sort of bounded method ...?

If you'd like to go for it, and your code is clean, following standards etc, I'll probably accept a pull request ... ^_^

polterguy avatar Mar 09 '22 21:03 polterguy