Skip to content

Commit 6742f3c

Browse files
committed
Log error instead of throwing an exception in release mode
1 parent 51e8f88 commit 6742f3c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Rubberduck.Inspections/Abstract/QuickFixBase.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using NLog;
45
using Rubberduck.Parsing.Inspections.Abstract;
56
using Rubberduck.Parsing.VBA;
67

78
namespace Rubberduck.Inspections.Abstract
89
{
910
public abstract class QuickFixBase : IQuickFix
1011
{
12+
private readonly ILogger _logger = LogManager.GetCurrentClassLogger();
1113
private HashSet<Type> _supportedInspections;
1214
public IReadOnlyCollection<Type> SupportedInspections => _supportedInspections.ToList();
1315

@@ -20,7 +22,12 @@ public void RegisterInspections(params Type[] inspections)
2022
{
2123
if (!inspections.All(s => s.GetInterfaces().Any(a => a == typeof(IInspection))))
2224
{
25+
#if DEBUG
2326
throw new ArgumentException($"Parameters must implement {nameof(IInspection)}", nameof(inspections));
27+
#else
28+
inspections.Where(s => s.GetInterfaces().All(i => i != typeof(IInspection))).ToList()
29+
.ForEach(i => _logger.Error($"Type {i.Name} does not implement {nameof(IInspection)}"));
30+
#endif
2431
}
2532

2633
_supportedInspections = inspections.ToHashSet();

0 commit comments

Comments
 (0)