DynamoDS/Dynamo — pull request #3340 by Randy-Ma (2014-12-02 08:45:28+00:00)
Title: Handling exceptions which are thrown when constructing elements

Summary

When constructing elements, there may be exceptions thrown but then the half-constructed elements may be registered with the life cycle manager. This will cause:
1). The half-constructed elements will never be disposed by us because they are half-constructed;
2). In the case, the element ID is registered with the life cycle manager, the related Revit element will not be deleted.

@lukechurch
This has been discussed and the conclusion is to catch the exceptions and unregister the ID with the life cycle manager if it is registered. But instead of adding the exception handling blocks everywhere, here we are passing a function from the derived class to the base class and the exception is handled there.

@sharadkjaiswal
More investigation makes me realize we can pass a function which takes an element as parameter.

There are many places to be changed. But before going so far, I want you to have a look. If it is good, I will continue.