Debug - AlsoGhostglowDev/Ghost-s-Utilities GitHub Wiki

debug.lua

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.)


Fields

dev: boolean = false
Turn this on to enable GhostUtil's developer mode. Forces errors, warnings and GhostUtil logs to be printed.
verFile: table<string> = { '3.0', 'release' }
A table containing the current version from ghostutil.version. Seperated with each newline.
version: string = '3.0'
Contains the first index of what verFile has, which should be the current GhostUtil version you have installed.
stage: string = 'release'
Contains the second index of what verFile has, which should be the current GhostUtil stage you have installed.
logs: table<string> = { }
Contains the logs that was passed through debug.log.
checkForUpdates: boolean = true
If GhostUtil should check for updates.

Methods

getCurrentVersion(): string

Fetches the currently installed GhostUtil version.

Returns: debug.version.

─────────────────────────

getCurrentStage(): string

Fetches the currently installed GhostUtil version stage.

Returns: debug.stage.

─────────────────────────

getLatest(index: number): string

Fetches 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(): string

Fetches the latest GhostUtil version.
(Shortcut to debug.getLatest(1))

Returns: GhostUtil's current latest version.

─────────────────────────

getLatestStage(): string

Fetches the latest GhostUtil stage.
(Shortcut to debug.getLatest(2))

Returns: GhostUtil's current latest stage.

─────────────────────────

isOutdated(): boolean

Checks whether the currently installed GhostUtil version is outdated compared to the GitHub.

Returns: Returns true if outdated.

─────────────────────────

warnOutdate(): void

Warns 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): void

Throws 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 be error, warning or deprecated.
  • 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 not nil, exception and formattedText'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): void

Throws 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 to debug.exception:1.
  • formattedText: refer to debug.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 not nil, exception and formattedText'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): void

Throws 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 to debug.exception:1.
  • formattedText: refer to debug.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 not nil, exception and formattedText'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): void

Stores 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 by debug.dev.


GhostUtil 3.0.0Docs 3.0.0, Revision 1

a Lua Library made by GhostglowDev; for Psych Engine
© 2025 GhostglowDevGhost's Utilities
Licensed under the MIT License.

⚠️ **GitHub.com Fallback** ⚠️