Skip to content

Feature Request: Small Scale Exception Handling #45

@MarleTangible

Description

@MarleTangible

Hello,

Performance improvements of TBEL over JavaScript is quite good. It is also very capable for a small scripting language. Although it's possible to let the script fail with an exception and use the failure path on the rule engine, more often than not I find myself looking for a small scale exception handling feature. Let me explain with an example.

We're using a small application where some telemetry information being collected, and due to other complexities some conversions and corrections needs to be made at the ThingsBoard level. One of these corrections is that one of the fields needs to be converted to datetime from string.

// 50 lines of code
var pattern = "hh:mm:ss a, EEE M/d/uuuu";
var date = new Date("12:15:30 PM, Sun 10/09/2022", pattern, "en-US");
// another 20 lines of code

The issue is that race conditions might cause malformed text to be sent, so I just would like to wrap it with a try {} catch {} and be done with it. I know it's hard to deal with stack unwinding and all the other complexities of creating a exception system for a scription language. So, maybe something similar to null-safe handling or AutoHotKey style processing can be done. e.g. just return null on exception under certain circumstances, maybe with the help of a keyword, AHK uses the Try keyword at the start of the line or just maybe allow try catch with a single level, but I think it would be really helpful, as so many issues require just a small correction and not a full scale failure of the script. I don't know how much you would like to divert from the MVEL language also.

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions