Skip to content
Bit Quirky Round Trip
Visual Scripting

Search documentation

All topics and APIs

Close returns focus to Search.

What are you looking for?

Try a common topic or enter a complete API identifier.

Browse the reference instead

Esc closes · Tab reaches results · Enter opens the focused link

v0.89.0
Menu

Return and throw

Read value returns, early guard exits, throw statements, rethrows, and throw expressions.

A door method should stop immediately when there is no player, the goal is locked, or the level already finished. Early return nodes make those guard exits visible before the successful path.

Door.Enter has three reasons to do nothing and one path that completes the level. Nesting the success path under three conditions would push the important work deeper with every rule. The method uses early returns to reject invalid cases first.

Use a return node at the normal end of a value-returning method or as an early exit. On the canvas a return node is titled EXIT. A return with an expression has a value input pin; return; in a void method has no value pin. Use throw when the method must terminate with an exception. A bare throw in catch rethrows the current exception. A throw expression can occupy supported value positions such as the right side of ??.

Door Enter with three early-return guards
Figure 1. Each failed condition leaves before the completion calls run.
  1. Open Door.Enter and follow the first branch. When player == null is true, its path reaches a return node and stops.

  2. Follow the false path to the next guard. When the door is not open, the method logs the locked state and returns.

  3. Follow the remaining path to the IsCompleted guard. Its true path returns without repeating completion work.

  4. Continue through all three false paths. This is the success spine: set completion, refresh the HUD, play audio, disable the player object, and log the result.

  5. To add an exit, place return from the flow-control actions. In a value-returning method it arrives with a value pin of the method’s return type; in a void method it has none. Connect the result expression to value: a wire supplies the expression, and an eligible unwired pin can hold an inline literal.

  6. Wire the return from the statement it follows. Compile writes it on the line after that statement, so a return wired after a statement inside an existing if lands inside that if. A chain of new set, return, or throw nodes wired from the entry node is written into the body before the first statement it leads into, or at the end, and that works in a method added in the same Compile.

  7. For an exception path, place throw from the exceptions actions, or inspect an existing throw node, and connect the exception expression. Use a rethrow only inside a catch where the current exception exists.

A value return writes return plus the expression on its value pin. A throw statement writes throw plus its exception expression. In a supported value position, a throw expression keeps forms such as input ?? throw new ArgumentNullException(nameof(input)) intact.

When it goes wrong

SymptomCheckFix
A return node has no value pin.Read the active method return type and whether the source says return with no expression.Use a value return only in a method whose signature returns a value.
Work after a guard never runs.Trace which branch output reaches the return node.Put the return on the rejecting path and keep the success spine on the other output.
A bare throw is refused outside catch.A rethrow needs a current caught exception.Move it inside the intended catch, or throw an explicit exception expression.
Full-size image