OrchardCore
OrchardCore copied to clipboard
added better description for partname being null
I'm seeing a lot of these errors when developing with orchard and there's not much help about it. So i decided to add a safeguard and some context when error is thrown
![image](https://user-images.githubusercontent.com/4034604/182372003-bff3e3b3-4772-420d-ac44-57c7b6447eff.png)
I also refactored a lot of this repetitive code into one method.
I realize that this refactor might not be what you want to see since it's a critical part of the system, so let me know if i went overboard:)
You may want to create an issue and explain the exact issue and how to reproduce it.
From my understanding, this happens when a content type has a part whose definition is either missing or has been removed from the system.
I also noticed slight inconsistency in how some of these methods were previously implemented.
Some of them fetch the part like this
while other do it like this:
ie. one is using part type, the other is using the part name. I think that content type part name is more correct
Looks good to me. We’ll see how the member feel about the change. I like the refactoring part, but, I am sure some will dislike it.
thanks. Do note about that discrepancy that i considered a bug where OnActivated a part is fetched with var part = context.ContentItem.Get(activator.Type, partName) as ContentPart; while most of them do it with var part = context.ContentItem.Get(activator.Type, typePartDefinition.Name) as ContentPart;
so i used the same private method and went with typePardDefinition.Name
This file has been changed tremendously since this PR