Skip to content

Add "Assert" Global Function #2206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Conversation

Zaurzo
Copy link
Contributor

@Zaurzo Zaurzo commented Feb 8, 2025

A custom assert function that has more features. Unlike the default assert function, this function allows you to provide a level to which the error is thrown at. It also has a noHalt argument to make the error not halt the code. The varargs are now used to format the error message.

Allowing to provide an error level will allow us to make it actually point to the faulting file, whereas the default assert only throws the error at stack level 1, making it seem like we caused the error.

For those with cases that need the error to not halt, or need to format the error message, this function has it built in for convenience, keeping it looking nice and clean.

On a successful assertion, it returns the expression value, the (formatted) error message, and all of the varargs.

Custom assert with more features, such as allowing to provide a level the error is thrown at, whether or not the error should halt, and the varargs are used to format the error message.
So that it returns the correct error level on successful assertion
So that, on successful assertion, it returns the error message properly formatted
There really isn't a need to return errorLevel and noHalt
@robotboy655 robotboy655 added the Addition The pull request adds new functionality. label Feb 13, 2025
@Aws0mee
Copy link
Contributor

Aws0mee commented Feb 15, 2025

Seems like a nice addition, but it might belong better in a 3rd party library imo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Addition The pull request adds new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants