Skip to content

Add Ruby exception handling#27

Merged
rhliang merged 3 commits into
mainfrom
AddRubyExceptionHandling
May 15, 2026
Merged

Add Ruby exception handling#27
rhliang merged 3 commits into
mainfrom
AddRubyExceptionHandling

Conversation

@rhliang
Copy link
Copy Markdown
Contributor

@rhliang rhliang commented May 13, 2026

Added an "exception case" output to interpret_from_json and added some exception handling on the Ruby side that would consume this output.

@rhliang rhliang added this to the v1.1 milestone May 13, 2026
@rhliang rhliang requested a review from va7eex May 13, 2026 23:18
@rhliang rhliang self-assigned this May 13, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (9ddd986) to head (96ad58c).
✅ All tests successful. No failed tests found.

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.
📢 Have feedback on the report? Share it here.

Comment thread ruby/lib/hla_algorithm.rb
Comment on lines +49 to +54
class Error < RuntimeError
end

class NoMatchingStandards < Error
end

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer these outside the class and called HLARuntimeError and HLANoMatchingStandardsError

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, keep it as-is. Although I think I'd be more comfortable if the base exception wasn't just called "Error".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread ruby/lib/hla_algorithm.rb Outdated

result = JSON.parse(python_stdout)
if result.key?('exception') && result['exception'] == 'no matching standards'
raise NoMatchingStandards.new()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This .new() looks strange to me.

@rhliang rhliang merged commit 9c78982 into main May 15, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants