This project contains the source code for the ExaError
Lua module. This module lets you define errors with a uniform set of attributes. The created error objects can be used in places where strings are expected like in string concatenation.
And you can conveniently raise a Lua error
from them.
Additionally, the resulting code is made to be parseable, so that you can extract an error catalog from the code.
Define an error object:
local ExaError = require("ExaError")
local errobj = ExaError:new("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:
print(errobj)
Raise a corresponding Lua error
errobj:raise()
Or shorter:
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"})
Check out the user guide for more details.
- Define error objects with error code, message, placeholders, parameters and mitigations
- Use error objects where strings are expected
- Raise errors from error objects
You can find corresponding libraries for other languages here:
The only runtime-dependency of this module is Lua 5.1 or later.
See the dependencies list for build and test dependencies and license information.