Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved error reporting for corrupted master page #976

Merged
merged 1 commit into from Apr 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -208,7 +208,14 @@ protected virtual void ValidateMasterPage(IAbstractTreeRoot root, IAbstractContr
if (masterPage == null)
return;
var viewModel = root.DataContextTypeStack.DataContextType;
if (!masterPage.DataContextType.IsAssignableFrom(viewModel))

if (masterPage.DataContextType is ResolvedTypeDescriptor typeDescriptor && typeDescriptor.Type == typeof(UnknownTypeSentinel))
{
masterPageDirective!.DothtmlNode!.AddError("Could not resolve the type of viewmodel for the specified master page. " +
$"This usually means that there is an error with the @viewModel directive in the master page file: \"{masterPage.FileName}\". " +
$"Make sure that the provided viewModel type is correct and visible for DotVVM.");
}
else if (!masterPage.DataContextType.IsAssignableFrom(viewModel))
{
masterPageDirective!.DothtmlNode!.AddError($"The viewmodel {viewModel.Name} is not assignable to the viewmodel of the master page {masterPage.DataContextType.Name}.");
}
Expand Down