Skip to content

Instantly share code, notes, and snippets.

@drhayes
Created February 13, 2020 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drhayes/bd02c7eba9fd4651227bb3f1f254a1d5 to your computer and use it in GitHub Desktop.
Save drhayes/bd02c7eba9fd4651227bb3f1f254a1d5 to your computer and use it in GitHub Desktop.
# From http://lua.space/general/assert-usage-caveat
function xassert(a, ...)
if a then return a, ... end
local f = ...
if type(f) == "function" then
local args = {...}
table.remove(args, 1)
error(f(unpack(args)), 2)
else
error(f or "assertion failed!", 2)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment