Add Ruby exception handling#27
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #27 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 5 5
Lines 803 803
Branches 116 116
=========================================
Hits 803 803 ☔ View full report in Codecov by Sentry. |
| class Error < RuntimeError | ||
| end | ||
|
|
||
| class NoMatchingStandards < Error | ||
| end | ||
|
|
There was a problem hiding this comment.
I would prefer these outside the class and called HLARuntimeError and HLANoMatchingStandardsError
There was a problem hiding this comment.
I'm on the fence about this, but the style in the code was just mimicking the code in the docs:
https://docs.ruby-lang.org/en/3.3/Exception.html#class-Exception-label-Custom+Exceptions
There was a problem hiding this comment.
In that case, keep it as-is. Although I think I'd be more comfortable if the base exception wasn't just called "Error".
There was a problem hiding this comment.
Thinking about this a little more, I think your suggestion is perhaps more Pythonic and works better in a language with stricter namespacing than Ruby.
|
|
||
| result = JSON.parse(python_stdout) | ||
| if result.key?('exception') && result['exception'] == 'no matching standards' | ||
| raise NoMatchingStandards.new() |
There was a problem hiding this comment.
This .new() looks strange to me.
Added an "exception case" output to
interpret_from_jsonand added some exception handling on the Ruby side that would consume this output.