Add 'Unhandled Error' warning to Script Analysis

As a Roblox developer, it is currently too hard to find places in code that do not handle functions that can throw.

Lua does not require that we handle errors, even though there should always be some method that handles errors. Occasionally, I will write a method (function) that can throw an error, and I will call said function without putting a pcall/xpcall around it. This can result in code throwing an error which is not handled, and will eventually have to be fixed. This becomes especially difficult to track down when there are roblox API methods that can throw an error. After all, there are only certain occasions where errors are thrown, and they often go unhandled in most Roblox developer’s code.

What I propose is that if a function can throw (i.e. contains assert() or error()), and whatever calls it is not put inside of a pcall/xpcall/etc, the Script Analysis will show a warning that reads something like: Unhandled Error.

If Roblox is able to address this issue, it would improve my development experience because it would enable me to more easily find blocks of code that do not properly handle errors, without relying on somebody encountering an error during bug testing.

4 Likes

Currently, afaik, Roblox’s predictive linter thingimajib doesn’t correctly handle assert conditions or error().

If I type a number into a function and it has an assert to force the first argument to be a string. The predictive linter should return the ‘assert failed’ error

On your topic of unhandled error, turning any logic error into a syntax error, and/or being able to correctly handle it, is a big :+1: from me.

2 Likes