#18449: Failing sage when an exception occurs in a notification provider

Work Item: 18449

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2012-02-27 11:33:31 -08:00
parent a15b1a8022
commit f3b39e3a4f
@@ -1,5 +1,7 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using Orchard.Logging;
using Orchard.UI.Notify; using Orchard.UI.Notify;
namespace Orchard.UI.Admin.Notification { namespace Orchard.UI.Admin.Notification {
@@ -8,11 +10,23 @@ namespace Orchard.UI.Admin.Notification {
public NotificationManager(IEnumerable<INotificationProvider> notificationProviders) { public NotificationManager(IEnumerable<INotificationProvider> notificationProviders) {
_notificationProviders = notificationProviders; _notificationProviders = notificationProviders;
Logger = NullLogger.Instance;
} }
public ILogger Logger { get; set; }
public IEnumerable<NotifyEntry> GetNotifications() { public IEnumerable<NotifyEntry> GetNotifications() {
return _notificationProviders return _notificationProviders
.SelectMany(n => n.GetNotifications()); .SelectMany(n => {
try {
return n.GetNotifications();
}
catch(Exception e) {
Logger.Error("An unhandled exception was thrown while generating a notification: " + n.GetType(), e);
return Enumerable.Empty<NotifyEntry>();
}
}).ToList();
} }
} }
} }