ichiban / prolog

The only reasonable scripting engine for Go.
MIT License
613 stars 29 forks source link

recover panic to promise #290

Closed ichiban closed 1 year ago

ichiban commented 1 year ago

An alternative solution for https://github.com/ichiban/prolog/pull/288

While #288 makes an interpreter transparent to panics, this PR makes it eagerly convert panics to Prolog exceptions.

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (207281f) 99.11% compared to head (afba508) 99.11%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #290 +/- ## ======================================= Coverage 99.11% 99.11% ======================================= Files 23 23 Lines 7201 7211 +10 ======================================= + Hits 7137 7147 +10 Misses 59 59 Partials 5 5 ``` | [Impacted Files](https://codecov.io/gh/ichiban/prolog/pull/290?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yutaka+Ichibangase) | Coverage Δ | | |---|---|---| | [engine/builtin.go](https://codecov.io/gh/ichiban/prolog/pull/290?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yutaka+Ichibangase#diff-ZW5naW5lL2J1aWx0aW4uZ28=) | `99.52% <100.00%> (+<0.01%)` | :arrow_up: | | [engine/promise.go](https://codecov.io/gh/ichiban/prolog/pull/290?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yutaka+Ichibangase#diff-ZW5naW5lL3Byb21pc2UuZ28=) | `100.00% <100.00%> (ø)` | | | [engine/vm.go](https://codecov.io/gh/ichiban/prolog/pull/290?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yutaka+Ichibangase#diff-ZW5naW5lL3ZtLmdv) | `94.46% <100.00%> (+0.04%)` | :arrow_up: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yutaka+Ichibangase). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yutaka+Ichibangase)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

guregu commented 1 year ago

Good idea IMO. I used a similar approach in trealla-js.