Skip to content
This repository was archived by the owner on Apr 6, 2024. It is now read-only.

Commit eef993e

Browse files
committed
Improve error message in case assembly is not loaded
1 parent c204724 commit eef993e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Cake.Issues.Reporting.Generic/RazorEngineReferenceResolver.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespace Cake.Issues.Reporting.Generic
22
{
3+
using System;
34
using System.Collections.Generic;
45
using System.IO;
56
using System.Linq;
@@ -35,7 +36,17 @@ public IEnumerable<CompilerReference> GetReferences(
3536

3637
private string FindLoaded(IEnumerable<string> refs, string find)
3738
{
38-
return refs.First(r => r.EndsWith(Path.DirectorySeparatorChar + find));
39+
var result = refs.FirstOrDefault(r => r.EndsWith(Path.DirectorySeparatorChar + find));
40+
41+
if (result == null)
42+
{
43+
throw new InvalidOperationException(
44+
string.Format(
45+
"Could not find loaded assembly {0}.",
46+
find));
47+
}
48+
49+
return result;
3950
}
4051
}
4152
}

0 commit comments

Comments
 (0)