-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commonize 'throw on view not found' #140
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,25 +13,42 @@ private ViewEngineResult() | |
|
||
public IView View { get; private set; } | ||
|
||
public string ViewName { get; private set; } | ||
|
||
public bool Success | ||
{ | ||
get { return View != null; } | ||
} | ||
|
||
public static ViewEngineResult NotFound([NotNull] IEnumerable<string> searchedLocations) | ||
public static ViewEngineResult NotFound([NotNull] string viewName, [NotNull] IEnumerable<string> searchedLocations) | ||
{ | ||
return new ViewEngineResult | ||
{ | ||
SearchedLocations = searchedLocations | ||
SearchedLocations = searchedLocations, | ||
ViewName = viewName, | ||
}; | ||
} | ||
|
||
public static ViewEngineResult Found([NotNull] IView view) | ||
public static ViewEngineResult Found([NotNull] string viewName, [NotNull] IView view) | ||
{ | ||
return new ViewEngineResult | ||
{ | ||
View = view | ||
View = view, | ||
ViewName = viewName, | ||
}; | ||
} | ||
|
||
public void ThrowIfViewNotFound() | ||
{ | ||
if (Success) | ||
{ | ||
return; | ||
} | ||
|
||
var locationsText = Environment.NewLine + string.Join(Environment.NewLine, SearchedLocations); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Tratcher it would be nice if the error page preserved formatting (pre tag). This way we don't need to do anything special for printing these out. Bonus points if you get it to support markdown There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. File a bug in DiagnosticPages. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AspNet/DiagnosticPages#6 logged by @pranavkm thanks! |
||
throw new InvalidOperationException(Resources.FormatViewEngine_ViewNotFound( | ||
ViewName, | ||
locationsText)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extra space |
||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public ViewEngineResult EnsureSuccessful().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍