Skip to main content
Version: 2.0.x (Unreleased)

Jungle Exception

The JungleException is Jungle's builtin exception object. This exception should be used inside node scripts when things go wrong during playback.

Jungle's runtime handles exception very strictly. This is purposeful, since running a sequence of code where one of the links malfunctions could be pretty wrong. If an exception is detected during node playback, the node is immediately stopped and then reported.


When to Throw Exceptions

Throw exceptions if anything during node playback goes critically wrong. For example, if a node looking for a game object couldn't find the game object, throw an exception.


Example

The example below shows a node named FindGameObjectNode that looks for a game object with the name 'MyGameObject'. In the case where the game object cannot be found, it throws an exception.

using Jungle;
using UnityEngine;

[IONode(OutputPortType = typeof(GameObject))]
public class FindGameObjectNode : IONode<Port.None>
{
protected override void OnStart(Port.None _)
{
GameObject gameObject = GameObject.Find("MyGameObject");

if (gameObject == null)
throw new JungleException("Failed to find a game object with the name MyGameObject");

CallAndStop(gameObject);
}

...
}