• Announcement: Lua.org now officially recommends this forum as a meeting place for the Lua community

Unified error reporting (1 Viewer)

redcatbear

Newcomer
Joined
Dec 16, 2020
Messages
4
Reaction score
5
If you ever thought, "wouldn't it be nice of all error messages in our applications would have a common style and were easy to search", then you might be interested in checking out the "exaerror" Lua rock.

In a Nutshell​

Define an error object:
Lua:
local errobj = exaerror.create("E-IO-13", "Need {{needed}} MiB space, but only {{remaining}} MiB left on device {{device}}.",
{needed = 500.2, remaining = 14.8, device = "/dev/sda4"})

Use it as string:
Lua:
print(errobj)

Raise a corresponding Lua error
Lua:
errobj.raise()

Or shorter:
Lua:
exaerror.error("E-IO-13", "Need {{needed}} MiB space, but only {{remaining}} MiB left on device {{device}}.",
{needed = 500.2, remaining = 14.8, device = "/dev/sda4"})

Supports unique error IDs, error messages with parameters and optional mitigation hints.

Check out the user guide for more details.

Links:
 
Top