Error Trapping with Dynamo

Hi all,

I have been searching the forums and found 1 or 2 posts that reference error trapping, but not quite what I am looking for…

I have a pretty massive script that I have developed to populate parameters of all categories based on a number of different criteria. The issue I am having is that once the script is run, it almost always says “Run completed with errors”. I know these errors to be benign in nature, but the end user doesn’t know that, and I constantly get asked what the errors are. Majority of the errors are caused by nulls, which I have gone through and filtered out of almost everything, but the parameters that get populated are quite vital to get right…
Is there anyway to notify the user of an error in Dynamo (whatever the error is) once the run is complete? This script has not been built with Python, it is all node information. I guess my main question is can I bring the errors to the users attention without using Python?

I usually help myself by defining some try/except blocks. If an except - block is triggered a key-value-pair <str elementID, str description> is stored in a list. I also clean up the input of values / data beforehand, where it can be assumed that they can cause a problem with if-conditions.
You probably also need nested try/except blocks in case there can be multiple error types / causes.

I output this error list via a PythonScript and save it into an excelfile if necessary.

It is probably more difficult with predefined nodes, where it is unclear when the error occurs.

Hi d.feyerer

Yes that is exactly my problem. The errors can move around the script for a number of different reasons, and at the moment it is impossible to tell whether the error is just a null or if the error has actually caused something to not be populated, which is a big deal to us.
I’m guessing there is no way to flexibly report an error to the user? Do you have to account for every possible error in your code or graph?

Depends a lot on the use case. I usually do something like unit tests for individual script components with separate Python scripts and fill them with a variable input, so that I can better estimate at which input parameters the error is thrown / what the error condition is. Often it is related to trivial reasons (e.g. items in list got wrong Object.Type etc.).

But I must also say that if the cause of the error is absolutely untraceable, I switch to several custom PythonScripts instead of predefined nodes, because this often makes the underlying problem more obvious / better recognizable. Of course, this requires a certain amount of time.

Maybe it works to create a subList with listitems (=input), that do not contain any problematic values (filter out all elements with value with if-statement: None and “null” and “Null” and 0 and “0” and str(“yourstring”) in str(list[i])) and gradually add each of these value to the sublist and check if the node / script then still returns error-free results.

In the case of python specific problems, it may also be helpful to recreate the problem in a python-online compiler and publish it on stackoverflow with a problem description.

1 Like

I really appreciate your time and insight with this! It gives me a direction to start looking and some things to try.
My concern is I might have to slowly migrate everything to Python so that I can incorporate error trapping as best as possible… but one thing at a time :slight_smile:

Thanks very much again!

1 Like

No need for python generally.

Function.Apply or List.Map (depending on your structure) can suppress the warnings (the language should not say error). Then you can do a List.Clean followed by a List.Count and compare that to the overall element count to know how many didn’t receive the value, and report that to the user (even with a list of element ids which it didn’t work for if you’d like).


Hi Jacob,

Thank you for your suggestion, this helps a lot and is much easier for me to implement as coding is not my strong point.

Thanks very much!

1 Like