[Ohrrpgce] assert that a particular piece of code has a script error?

James Paige Bob at hamsterrepublic.com
Tue Jan 9 08:32:15 PST 2018


On Tue, Jan 9, 2018 at 8:17 AM, Ralph Versteegen <teeemcee at gmail.com> wrote:

>
>
> On 10 January 2018 at 05:12, Ralph Versteegen <teeemcee at gmail.com> wrote:
>
>> There's no such feature. Its absence is certainly a nuisance for writing
>> test cases.
>> (hspeaktest.py can check for compile-time warnings and errors, but not
>> run-time ones)
>>
>> I didn't have any ideas for a try/except block statement. I thought that
>> people wouldn't use it much since most wouldn't be familiar with
>> exceptions, and the additional complexity, didn't seem to justify it.
>> But maybe a more coarse-grained ability to specify a global (or
>> per-script or per-fibre) error handler would be useful. Either just for our
>> purposes, or as a public feature.
>> Incidentally, lua doesn't have try/except, but it has a special way to
>> call a function so that you catch errors inside it (pcall).
>>
>
> Also, when it comes to the differences between release and debug modes, I
> suppose that you could use error catching either to catch errors that will
> actually be shown to the user (so you can customise that), or to catch
> errors (oh a certain errorlevel?) regardless of whether they're shown,
> which useful for testcases... but what use would there be? Because we want
> to be able to assume everyone uses release mode, and add new error
> checking, I think any other uses of error checking would make adding more
> error checking a back-compat problem again :/
>
>

I think something like lua's pcall would be great. I just thought of
try/except since that Is what I am most familiar with.

Just checking user-visible errors seems good enough for writing better test
cases, since it should be very little trouble making sure that autotest.rpg
gets run in debug mode (it looks like we don't currently have a command
line argument to force testing mode, but it ought to be easy to add one)

---
James
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.motherhamster.org/pipermail/ohrrpgce-motherhamster.org/attachments/20180109/96c39aa1/attachment-0001.html>


More information about the Ohrrpgce mailing list