beanshell / beanshell

Beanshell scripting language
Apache License 2.0
815 stars 183 forks source link

EvalError vs dynamic language exception causes #556 #758

Closed opeongo closed 1 month ago

opeongo commented 3 months ago

This is a fix for issue #556

Catch evaluation errors that are caused by common scripting errors: syntax, name lookup failures, etc. Allow the BeanShell script authors to catch these exceptions and attempt recovery or graceful shutdown.

The new class EvalException is a subclass of EvalError. This will be used by benign exceptions where the interpreter can simply unwind from the point of error and carry on in the catch or finally block.

codecov[bot] commented 3 months ago

Codecov Report

Attention: 8 lines in your changes are missing coverage. Please review.

Comparison is base (2ffb804) 74.24% compared to head (5934e52) 74.40%.

Files Patch % Lines
src/main/java/bsh/UtilEvalError.java 28.57% 3 Missing and 2 partials :warning:
src/main/java/bsh/BSHTryStatement.java 71.42% 1 Missing and 1 partial :warning:
src/main/java/bsh/BSHType.java 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #758 +/- ## ============================================ + Coverage 74.24% 74.40% +0.15% - Complexity 3042 3053 +11 ============================================ Files 108 109 +1 Lines 9357 9375 +18 Branches 1857 1859 +2 ============================================ + Hits 6947 6975 +28 + Misses 2070 2062 -8 + Partials 340 338 -2 ``` | [Flag](https://app.codecov.io/gh/beanshell/beanshell/pull/758/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=beanshell) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/beanshell/beanshell/pull/758/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=beanshell) | `74.40% <86.88%> (+0.15%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=beanshell#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

nickl- commented 1 month ago

This was a huge help, thank you @opeongo