+2 votes

Another question already asked about raising an error, but their question was really asking how to stop the debugger at a given point. And so the answer addressed that real question rather than how to raise an error (additionally, the question is a few years old now and may hav changed). Is there a way to actually raise an error? Preferably passing an error message? Thank you!

in Engine by (107 points)

What do you mean by "raise an error"?

I think it's related to the concept of exception handling, Zylann.

Godot doesn't suppot exceptions, at least not like common languages do it. It only has asserts or error prints. Is it about the latter?

I think it's about printing an error. Or more of, when the program is executing, the programmer would like to handle an error the best way they can. For example, what I usually do when I can catch an error, I use the following:

if (foo != "bar"):
    print("It's not a foobar!")
    get_tree().quit()

I hope that clears things up.

1 Answer

+3 votes

If you want to have a message appear in godot's built-in debugging tools, you can do so by "pushing" errors or warnings...

push_warning ( String message )
push_error ( String message )

Here's a Link to the Documentation.

I hope it's the same concept you referred to with "raising" warnings/errors.

by (23 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.