mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-20 17:41:37 +00:00
Add 'invariant' function for debugging
This commit is contained in:
parent
cf62ee5ccb
commit
1ee679395d
1 changed files with 27 additions and 0 deletions
27
plugin/src/invariant.lua
Normal file
27
plugin/src/invariant.lua
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
local Config = require(script.Parent.Config)
|
||||
|
||||
local invariant
|
||||
|
||||
if Config.isDevBuild then
|
||||
function invariant(message, ...)
|
||||
message = string.format(message, ...)
|
||||
|
||||
error("Invariant violation: " .. message, 2)
|
||||
end
|
||||
else
|
||||
function invariant(message, ...)
|
||||
message = string.format(message, ...)
|
||||
|
||||
local fullMessage = string.format(
|
||||
"Rojo detected an invariant violation within itself:\n" ..
|
||||
"%s\n\n" ..
|
||||
"This is a bug in Rojo. Please file an issue:\n" ..
|
||||
"https://github.com/rojo-rbx/rojo/issues",
|
||||
message
|
||||
)
|
||||
|
||||
error(fullMessage, 2)
|
||||
end
|
||||
end
|
||||
|
||||
return invariant
|
||||
Loading…
Add table
Add a link
Reference in a new issue