Debug - AlsoGhostglowDev/Ghost-s-Utilities GitHub Wiki
GhostUtil's backend debugger used to report errors and warnings to user.
local debug = require 'ghostutil.debug'(module name may conflict with Lua's existing debug library.)
dev: boolean = falseverFile: table<string> = { '3.0', 'release' }ghostutil.version. Seperated with each newline.
version: string = '3.0'verFile has, which should be the current GhostUtil version you have installed.
stage: string = 'release'verFile has, which should be the current GhostUtil stage you have installed.
logs: table<string> = { }debug.log.
checkForUpdates: boolean = truegetCurrentVersion(): stringFetches the currently installed GhostUtil version.
Returns: debug.version.
─────────────────────────
getCurrentStage(): stringFetches the currently installed GhostUtil version stage.
Returns: debug.stage.
─────────────────────────
getLatest(index: number): stringFetches the latest information from GhostUtil's GitHub.
(fetched from here)
Parameters:
-
index: The line number of where the target information is.
Returns: GhostUtil's latest version information of the given index.
View Example
-- fetches the latest GhostUtil version.
debug.getLatest(1)─────────────────────────
getLatestVersion(): stringFetches the latest GhostUtil version.
(Shortcut to debug.getLatest(1))
Returns: GhostUtil's current latest version.
─────────────────────────
getLatestStage(): stringFetches the latest GhostUtil stage.
(Shortcut to debug.getLatest(2))
Returns: GhostUtil's current latest stage.
─────────────────────────
isOutdated(): booleanChecks whether the currently installed GhostUtil version is outdated compared to the GitHub.
Returns: Returns true if outdated.
─────────────────────────
warnOutdate(): voidWarns user to update their GhostUtil library if outdated.
(Intended for developer-only use)
─────────────────────────
exception(!exception: string, exceptionType: string, formattedText: table<dynamic>, ?func: string, !exceptionMsg: string, ?level: number): voidThrows a GhostUtil exception with the provided exception message. (Intended for developer-only use)
-
exception(one-or-another): Reason for the exception that's about to be thrown. However, you can leave this as an empty string if you're planning to throw a custom exception.
List of available exceptions and their corresponding format:
'nil_param': Expected a value for parameter %s. (1)'no_eq': Parameter %s can't be the same as %s! (2)'no_eq_tbl': Values in table from parameter %s cannot be the same! (1)'wrong_type': Expected %s, got %s instead. (2)'less_len': Insufficient table length in parameter %s.
Expected length to be %s, got %s instead. (3)'over_len': Too much elements in table in parameter %s.
Expected length to be %s, got %s instead. (3)'missing_el': Missing element "%s" from %s. (2)'unrecog_el': Unrecognized element "%s" from %s. (2)'outdated': You're using an outdated version of GhostUtil (%s).
Please update to the latest version: %s. (2)
-
exceptionType: The exception type, can beerror,warningordeprecated. -
formattedText: A table containing the text you want to replace the placeholder in the format to. The table's length must match the amount of placeholders in the given format, you can check how many in the list of available exceptions. -
func(optional): The function name that this exception originated from. Defaults to an empty string. -
exceptionMsg(one-or-another): The custom exception message, if this is notnil,exceptionandformattedText's will be ignored, else the formatted text is used instead. Defaults to an empty string. -
level(optional): The level of the file information, fetches the top-level information by default.
View Example
-- assuming this is in 'test.lua' on line 32
-- prints 'GHOSTUTIL ERROR: test.lua:32: myModule.printer: Expected a value for parameter "message".'
debug.exception('nil_param', 'error', {'message'}, 'myModule.printer')─────────────────────────
error(!exception: string, formattedText: table<dynamic>, ?func: string, !forcedMsg: string, level: number): voidThrows a GhostUtil error with the provided exception message.
(Shortcut to debug.exception(.., 'error', {..}, .., .., ..), intended for developer-only use)
Parameters:
-
exception(one-or-another): Reason for the exception, refer todebug.exception:1. -
formattedText: refer todebug.exception:3. -
func(optional): The function name that this exception orginated from. Defaults to an empty string. -
forcedMsg(one-or-another): The custom exception message, if this is notnil,exceptionandformattedText's contents will be ignored, else the formatted text is used instead. Defaults to an empty string. -
level: (optional): The level of the file information, fetches the top-level information by default.
View Example
-- maybe someone messed up the types.
local thing = '89' -- this was supposed to be a number, but it's a string
-- assuming this is in 'test.lua' on line 32
-- prints 'GHOSTUTIL ERROR: test.lua:32: myModule.fn: Expected number, got string instead.'
debug.error('wrong_type', {'number', type(thing)}, 'myModule.fn')
-- you can also do "myModule.fn:1" for the function name,
-- the "1" refers to what parameter was wrong and is throwing an exception.
-- this gives the user more information to what's causing the error.─────────────────────────
warning(!exception: string, formattedText: table<dynamic>, ?func: string, !forcedMsg: string, level: number): voidThrows a GhostUtil warning with the provided exception message.
(Shortcut to debug.exception(.., 'warning', {..}, .., .., ..), intended for developer-only use)
Parameters:
-
exception(one-or-another): Reason for the exception, refer todebug.exception:1. -
formattedText: refer todebug.exception:3. -
func(optional): The function name that this exception orginated from. Defaults to an empty string. -
forcedMsg(one-or-another): The custom exception message, if this is notnil,exceptionandformattedText's contents will be ignored, else the formatted text is used instead. Defaults to an empty string. -
level: (optional): The level of the file information, fetches the top-level information by default.
View Example
-- throws a custom warning message!:
-- assuming this is in 'test.lua' on line 32
-- prints 'GHOSTUTIL WARNING: test.lua:32: myModule.fn: You did something wrong.'
debug.warning('', {}, 'myModule.fn', 'You did something wrong.')─────────────────────────
log(msg: string, ?printLog: boolean): voidStores the logged message in debug.logs for debugging purposes.
Parameters:
-
msg: The log message. -
printLog(optional): If it should print the logged message onto the screen, defaults to false. However, it can be bypassed bydebug.dev.
GhostUtil 3.0.0 • Docs 3.0.0, Revision 1
a Lua Library made by GhostglowDev; for Psych Engine
© 2025 GhostglowDev — Ghost's Utilities
Licensed under the MIT License.