Module Error
Produces auto-formatting auto-serializing errors handlers.
Module Status: Experimental 2020-10-31.
Usage:
local Error = require('__eradicators-library__/erlib/factorio/Error')()
Error.Error('MyModName','MyErrorName',"Sorry, i can't do that Dave!",nil,nil, nil,'shit',{'is','hitting',{'the','fence!'}},{'near','the','fox'}, nil,nil,nil )
> ##### [MyModName : MyErrorName] ##### > I suspected this might happen. Please tell me how you got here. > > Sorry, i can't do that Dave! > shit > {"is", "hitting", {"the", "fence!"}} > {"near", "the", "fox"} > > (6 nil values removed.) > control.lua:18 > some_module.lua:67 > ############################
Functions
Error([prefix[, postfix[, ...]]]) | The raw error handler called by all Error instances. |
Stopper([prefix="YourModName"], postfix) | Fabricates a customized ErrorRaiser with closurized prefix and postfix. |
Asserter(error_raiser) | Assert, but with a custom error function. |
ErrorRaiser
ErrorRaiser([...]) | Raises an error with the given message and the closurized pre- and postfix. |
Functions
- Error([prefix[, postfix[, ...]]])
-
The raw error handler called by all Error instances.
Will print an error message as shown above. All varargs will be serialized
if required and printed one per line.
Parameters:
- Stopper([prefix="YourModName"], postfix)
-
Fabricates a customized ErrorRaiser
with closurized prefix and postfix.
Parameters:
Returns:
Raises:
CustomErrorUsage:
local MyError = Error.Stopper('MyModName','MyErrorName') if not is_everything_ok then MyError('something is broken!') end
local MyError = Error.Stopper('MyErrorName') if not is_everything_ok then MyError('something is broken!') end
- Asserter(error_raiser)
-
Assert, but with a custom error function.
Parameters:
- error_raiser ErrorRaiser
Returns:
ErrorRaiser
- ErrorRaiser([...])
-
Raises an error with the given message and the closurized pre- and postfix.
Parameters:
- ... AnyValue Arbitrary values to be displayed in the error message. (optional)
Raises:
CustomError