Skip to content

Commit 0b15e10

Browse files
committed
Handle template creation failures with the template engine
Check the status of the result and throw an exception with information about the failure. This will aid diagnosing problems with the template. Previously a null reference exception would be thrown as an attempt was made to use the TemplateCreationResult's ResultInfo which would be null.
1 parent ccf7980 commit 0b15e10

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/MonoDevelop.TemplateCreator/MonoDevelop.Templating/TemplateProcessor.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ public async Task<ProcessedTemplateResult> ProcessTemplate ()
7474
var parameters = new Dictionary<string, string> ();
7575
var result = await templateEngine.Create (template, config, parameters);
7676

77+
if (result.Status != CreationResultStatus.Success) {
78+
string message = GettextCatalog.GetString ("Could not create template. Id='{0}' {1} {2}", template.Id, result.Status, result.Message);
79+
throw new InvalidOperationException (message);
80+
}
81+
7782
List<string> filesToOpen = GetFilesToOpen (result).ToList ();
7883
workspaceItems = await GetWorkspaceItems (result);
7984

0 commit comments

Comments
 (0)