Skip to content

exasol/error-reporting-lua

Repository files navigation

Error Reporting Lua

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.

In a Nutshell

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.

Features

  1. Define error objects with error code, message, placeholders, parameters and mitigations
  2. Use error objects where strings are expected
  3. Raise errors from error objects

Information for Users

You can find corresponding libraries for other languages here:

Dependencies

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.