Is it possible to throw an error in blueprint?

I have a trigger blueprint and I have a door blueprint that has an array of trigger blueprints. I would like to throw an error if there is no trigger to one of the logs so that I can click on the asset in question and it would jump me straight to the door that’s missing a trigger. I’ve seen similar things happen with lighting and other assets.

4 Likes

I would like to know this as well

Can you elaborate further? If you have trigger blueprints within your door blueprint, why would it be different for different door instances?

EDIT: just noticed this is like a year old… Same question to you . Can you elaborate further on what you would like to achieve?

Hmm, I kinda get you, but then again I never really had that sort of problem. I don’t know of any nodes that can output into the error log as such unfortunately.

You know how you could have map errors that show up after a build. I would like it so that if one of my triggers doesn’t have a target, it shows up in the map errors.

Granted I discovered child actors since this and am using a blueprint that combines a trigger BP and a door BP, but I can still trigger the door with extra triggers if needed. So it would be nice, but not nearly as important.

For example. If you try to spawn a class without a transform the blueprint won’t compile. The transform is required. I would like to specify that a target is a requirement for a trigger in a similar way.

I actually want to raise an actual crash. Like a game crash. Quiet often there is a mistake in a blueprint somewhere (like retrieving an item from an array of objects that contains nil values) but the editor instead reports errors on ANOTHER blueprint on a really silly part like a branch-node. A branch node can’t be out range but okay… Then I have to start the epic search for the actual error somewhere through all of those blueprints. Currently I use print-string with some text like: “ERROR: in blueprint x”. Anyway, the editor just doesn’t like nil-values and goes all crazy on me if there is an accidental nil-value.

Adding my vote for this. My scenario is similar I have a blueprint that requires 1 and only 1 of another blueprint. I search for it using GetAllActorsOfClass and if there is 0 or >1 then I’d like to let the map designer know there is an error somehow.

Is there a good way to solve this scenario?

I would like to vote this up too.
Due to the fact that it is impossible to load an asst simply by having it’s name string, I am forced to create huge switch constructs in blueprint to make a spawnactor node for every class imaginable. When I add new classes, I have to add them everywhere where I spawn them, so the least thing to make this task easier would be to be able to crash a program with an error message.
Currently I use a C++ function for this

+1 would love a way to handle invalid input in a function for example

Hi everyone,

I’m trying to fully understand what exactly you’re looking for that is not present within the editor already. In the original post, you are asking for a means to select a specific asset when a trigger fails within the message log. Depending on the specific context, assets that receive certain types of errors already allow you to do this to some degree. Have you tried adding Is Valid checks within your blueprints as well? There are numerous ways to ensure that your trigger fires when it is supposed to. If I could get some clarification on exactly what you are looking for it may help.

What I’m looking for (can’t speak for the others): I’m writing a Blueprint function. I receive a call with invalid parameters. What are my options now?

  • Do nothing: very hard to debug what went wrong because the effect might show up somewhere very far, or I might not notice for some time.
  • Return a boolean success: feasible but it means I have to add success checks everywhere which turns into a pain
  • Do something cheesy like make a big exclamation mark visible in the editor: sure but it’s hard to generalize, and assuming my function is called repeatedly and in many places, I can’t tell which one is wrong.
  • Print some message in the console: similar problems, hard to generalize, might not notice if I’m looking at something else, etc

What I’d like would be something like one of these:

  • assert fail: in the editor, execution stops and debugger shows me where I am (I can then check the execution trace to see what’s happening). In production… ignored? crashes? make it a setting?
  • exception handling :smiley: (sorry, I come from a long history of languages that support it) - when unhandled, the editor/debugger steps in
  • a dedicated/first-class way to report an error state that is easily visible in the editor, preferably including all locals, parameters and stack-trace

If any of these exist already, tell me - I’m new at this.

Cheers!

Have you checked the message log for the errors you are searching for? If you go to Window>Developer Tools>Message Log. When you do, you’ll get this window:

This breaks down what errors you get as you get them and can be used during PIE to see what specifically is occurring. Does this cover what you are looking for? For example, if you run a test that gives you a blatantly null value, the specific instance error should appear when you activate it during PIE, the error will appear in the message log detailing what exactly occurred. In many cases, the specific assets/nodes will be listed and linked, as below:

1 Like

Here is one instance when I would like to throw an error from a Blueprint:

  • I’m setting a variable during Construction Script or the Begin Play Event, but that I didn’t find an object instance like I needed. (I want to know then - not later when the blueprint tries to use the variable.)

Put breakpoint, it will pause the code and show you when node is triggered

1 Like

First of all, it might be better to have your trigger be part of the door blueprint and thus make suré it’s Always there. Second, inside your door blueprint add a spawn player character next to it so it will open. Add a print string for when it opens. Inside the string would be the BP name. If done correctly you would get a list of strings of all doors that work. You can easily isolate the doors that don’t work that way.

breakpoints ? this is weak

Same here; EVERY programming language has a way to explicitly catch/flag errors explicitly. This is basic stuff.

Anyhow, best I can see is creating a BLUEPRINT LIBRARY function and putting a breakpoint there, so it’s all centralized.

Agreed, I just ran into an scenario where I would like to throw an error, even if just for a quick test.

+1 vote. For whatever reason, I would like to throw an exception/error which crashes the game under certain conditions – in blueprint. In C++ I might for example write something like

throw std::runtime_error( "received negative value" );

or in C#

throw new Exception( "received negative value" );