Normalizing all catch (Exception ex) lines and adding exception fatality check where applicable, fixes #3949

This commit is contained in:
Lombiq
2015-09-07 00:17:57 +02:00
parent 14482162fd
commit a685517118
33 changed files with 217 additions and 66 deletions

View File

@@ -89,9 +89,9 @@ namespace Orchard.WarmupStarter {
var result = _initialization(application);
_initializationResult = result;
}
catch (Exception e) {
catch (Exception ex) {
lock (_synLock) {
_error = e;
_error = ex;
_previousError = null;
}
}

View File

@@ -17,6 +17,7 @@ using Orchard.UI.Navigation;
using Orchard.Utility;
using System;
using Orchard.Logging;
using Orchard.Exceptions;
namespace Orchard.Core.Navigation.Controllers {
[ValidateInput(false)]
@@ -179,6 +180,10 @@ namespace Orchard.Core.Navigation.Controllers {
return View(model);
}
catch (Exception exception) {
if (exception.IsFatal()) {
throw;
}
Logger.Error(T("Creating menu item failed: {0}", exception.Message).Text);
Services.Notifier.Error(T("Creating menu item failed: {0}", exception.Message));
return this.RedirectLocal(returnUrl, () => RedirectToAction("Index"));

View File

@@ -11,6 +11,7 @@ using Orchard.Security.Permissions;
using Orchard.UI;
using Orchard.UI.Navigation;
using Orchard.Utility;
using Orchard.Exceptions;
namespace Orchard.Core.Navigation.Services {
public class NavigationManager : INavigationManager {
@@ -152,6 +153,9 @@ namespace Orchard.Core.Navigation.Services {
items = builder.Build();
}
catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
Logger.Error(ex, "Unexpected error while querying a navigation provider. It was ignored. The menu provided by the provider may not be complete.");
}
if (items != null) {
@@ -170,6 +174,9 @@ namespace Orchard.Core.Navigation.Services {
items = builder.Build();
}
catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
Logger.Error(ex, "Unexpected error while querying a menu provider. It was ignored. The menu provided by the provider may not be complete.");
}
if (items != null) {
@@ -188,6 +195,9 @@ namespace Orchard.Core.Navigation.Services {
imageSets = builder.BuildImageSets();
}
catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
Logger.Error(ex, "Unexpected error while querying a navigation provider. It was ignored. The menu provided by the provider may not be complete.");
}
if (imageSets != null) {

View File

@@ -9,6 +9,7 @@ using Orchard.Logging;
using Orchard.Services;
using Orchard.Tasks;
using Orchard.Tasks.Scheduling;
using Orchard.Exceptions;
namespace Orchard.Core.Scheduling.Services {
[UsedImplicitly]
@@ -65,6 +66,9 @@ namespace Orchard.Core.Scheduling.Services {
}
}
catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
Logger.Warning(ex, "Unable to process scheduled task #{0} of type {1}", taskEntry.Id, taskEntry.Action);
_transactionManager.Cancel();
}

View File

@@ -11,6 +11,7 @@ using Orchard.Logging;
using Orchard.Security;
using Orchard.Settings;
using Orchard.UI.Notify;
using Orchard.Exceptions;
namespace Orchard.Core.Settings.Drivers {
[UsedImplicitly]
@@ -102,9 +103,12 @@ namespace Orchard.Core.Settings.Drivers {
using (request.GetResponse() as HttpWebResponse) {}
}
}
catch (Exception e) {
catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
_notifier.Warning(T("The base url you entered could not be requested from current location."));
Logger.Warning(e, "Could not query base url: {0}", model.Site.BaseUrl);
Logger.Warning(ex, "Could not query base url: {0}", model.Site.BaseUrl);
}
}
}

View File

@@ -9,6 +9,7 @@ using Orchard.ContentManagement.MetaData.Services;
using Orchard.Core.Settings.Metadata.Records;
using Orchard.Data;
using Orchard.Logging;
using Orchard.Exceptions;
namespace Orchard.Core.Settings.Metadata {
public class ContentDefinitionManager : Component, IContentDefinitionManager {
@@ -282,6 +283,9 @@ namespace Orchard.Core.Settings.Metadata {
return XElement.Parse(settings);
}
catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
Logger.Error(ex, "Unable to parse settings xml");
return null;
}

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using Orchard.Logging;
using Orchard.Exceptions;
namespace Orchard.Caching {
public class DefaultAsyncTokenProvider : IAsyncTokenProvider {
@@ -37,9 +38,12 @@ namespace Orchard.Caching {
try {
_task(token => _taskTokens.Add(token));
}
catch (Exception e) {
Logger.Error(e, "Error while monitoring extension files. Assuming extensions are not current.");
_taskException = e;
catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
Logger.Error(ex, "Error while monitoring extension files. Assuming extensions are not current.");
_taskException = ex;
}
finally {
_isTaskFinished = true;

View File

@@ -15,6 +15,7 @@ using Orchard.FileSystems.VirtualPath;
using Orchard.Localization;
using Orchard.Logging;
using Orchard.Tasks;
using Orchard.Exceptions;
namespace Orchard.Commands {
@@ -94,19 +95,21 @@ namespace Orchard.Commands {
return CommandReturnCodes.Ok;
}
catch (OrchardCommandHostRetryException e) {
catch (OrchardCommandHostRetryException ex) {
// Special "Retry" return code for our host
output.WriteLine(T("{0} (Retrying...)", e.Message));
output.WriteLine(T("{0} (Retrying...)", ex.Message));
return CommandReturnCodes.Retry;
}
catch (Exception e) {
if (e is TargetInvocationException &&
e.InnerException != null) {
// If this is an exception coming from reflection and there is an innerexception which is the actual one, redirect
e = e.InnerException;
catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
OutputException(output, T("Error executing command \"{0}\"", string.Join(" ", args)), e);
if (ex is TargetInvocationException &&
ex.InnerException != null) {
// If this is an exception coming from reflection and there is an innerexception which is the actual one, redirect
ex = ex.InnerException;
}
OutputException(output, T("Error executing command \"{0}\"", string.Join(" ", args)), ex);
return CommandReturnCodes.Fail;
}
}
@@ -116,13 +119,16 @@ namespace Orchard.Commands {
_hostContainer = CreateHostContainer();
return CommandReturnCodes.Ok;
}
catch (OrchardCommandHostRetryException e) {
catch (OrchardCommandHostRetryException ex) {
// Special "Retry" return code for our host
output.WriteLine(T("{0} (Retrying...)", e.Message));
output.WriteLine(T("{0} (Retrying...)", ex.Message));
return CommandReturnCodes.Retry;
}
catch (Exception e) {
OutputException(output, T("Error starting up Orchard command line host"), e);
catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
OutputException(output, T("Error starting up Orchard command line host"), ex);
return CommandReturnCodes.Fail;
}
}
@@ -135,8 +141,11 @@ namespace Orchard.Commands {
}
return CommandReturnCodes.Ok;
}
catch (Exception e) {
OutputException(output, T("Error shutting down Orchard command line host"), e);
catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
OutputException(output, T("Error shutting down Orchard command line host"), ex);
return CommandReturnCodes.Fail;
}
}

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Orchard.Localization;
using Orchard.Exceptions;
namespace Orchard.Commands {
public abstract class DefaultOrchardCommandHandler : ICommandHandler {
@@ -41,12 +42,15 @@ namespace Orchard.Commands {
object value = Convert.ChangeType(commandSwitch.Value, propertyInfo.PropertyType);
propertyInfo.SetValue(this, value, null/*index*/);
}
catch(Exception e) {
catch(Exception ex) {
if (ex.IsFatal()) {
throw;
}
string message = T("Error converting value \"{0}\" to \"{1}\" for switch \"{2}\"",
LocalizedString.TextOrDefault(commandSwitch.Value, T("(empty)")),
propertyInfo.PropertyType.FullName,
commandSwitch.Key).Text;
throw new InvalidOperationException(message, e);
throw new InvalidOperationException(message, ex);
}
}

View File

@@ -3,6 +3,7 @@ using System.Linq;
using Orchard.Environment;
using Orchard.Environment.Features;
using Orchard.Logging;
using Orchard.Exceptions;
namespace Orchard.Data.Migration {
/// <summary>
@@ -41,8 +42,11 @@ namespace Orchard.Data.Migration {
try {
_dataMigrationManager.Update(feature);
}
catch (Exception e) {
Logger.Error("Could not run migrations automatically on " + feature, e);
catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
Logger.Error("Could not run migrations automatically on " + feature, ex);
}
}
}

View File

@@ -9,6 +9,7 @@ using Orchard.Data.Migration.Schema;
using Orchard.Environment.Extensions;
using Orchard.Localization;
using Orchard.Logging;
using Orchard.Exceptions;
namespace Orchard.Data.Migration {
/// <summary>
@@ -123,6 +124,9 @@ namespace Orchard.Data.Migration {
current = (int)lookupTable[current].Invoke(migration, new object[0]);
}
catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
Logger.Error(ex, "An unexpected error occurred while applying migration on {0} from version {1}.", feature, current);
throw;
}
@@ -139,10 +143,13 @@ namespace Orchard.Data.Migration {
dataMigrationRecord.Version = current;
}
}
catch (Exception e) {
Logger.Error(e, "Error while running migration version {0} for {1}.", current, feature);
catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
Logger.Error(ex, "Error while running migration version {0} for {1}.", current, feature);
_transactionManager.Cancel();
throw new OrchardException(T("Error while running migration version {0} for {1}.", current, feature), e);
throw new OrchardException(T("Error while running migration version {0} for {1}.", current, feature), ex);
}
}

View File

@@ -1,6 +1,7 @@
using System;
using Orchard.Data.Migration.Interpreters;
using Orchard.Localization;
using Orchard.Exceptions;
namespace Orchard.Data.Migration.Schema {
public class SchemaBuilder {
@@ -65,6 +66,9 @@ namespace Orchard.Data.Migration.Schema {
Run(sqlStatmentCommand);
return this;
} catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
throw new OrchardException(T("An unexpected error occured while executing the SQL statement: {0}", sql), ex); // Add the sql to the nested exception information
}
}

View File

@@ -11,6 +11,7 @@ using Orchard.Environment.ShellBuilders.Models;
using Orchard.FileSystems.AppData;
using Orchard.Logging;
using Orchard.Utility;
using Orchard.Exceptions;
namespace Orchard.Data {
public class SessionConfigurationCache : ISessionConfigurationCache {
@@ -80,11 +81,11 @@ namespace Orchard.Data {
formatter.Serialize(stream, cache.Configuration);
}
}
catch (SerializationException e) {
catch (SerializationException ex) {
//Note: This can happen when multiple processes/AppDomains try to save
// the cached configuration at the same time. Only one concurrent
// writer will win, and it's harmless for the other ones to fail.
for (Exception scan = e; scan != null; scan = scan.InnerException)
for (Exception scan = ex; scan != null; scan = scan.InnerException)
Logger.Warning("Error storing new NHibernate cache configuration: {0}", scan.Message);
}
}
@@ -118,8 +119,11 @@ namespace Orchard.Data {
};
}
}
catch (Exception e) {
for (var scan = e; scan != null; scan = scan.InnerException)
catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
for (var scan = ex; scan != null; scan = scan.InnerException)
Logger.Warning("Error reading the cached NHibernate configuration: {0}", scan.Message);
Logger.Information("A new one will be re-generated.");
return null;

View File

@@ -13,6 +13,7 @@ using Orchard.Environment.Descriptor.Models;
using Orchard.Localization;
using Orchard.Logging;
using Orchard.Utility.Extensions;
using Orchard.Exceptions;
namespace Orchard.Environment {
// All the event handlers that DefaultOrchardHost implements have to be declared in OrchardStarter
@@ -140,8 +141,11 @@ namespace Orchard.Environment {
var context = CreateShellContext(settings);
ActivateShell(context);
}
catch (Exception e) {
Logger.Error(e, "A tenant could not be started: " + settings.Name);
catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
Logger.Error(ex, "A tenant could not be started: " + settings.Name);
}
while (_processingEngine.AreTasksPending()) {
Logger.Debug("Processing pending task after activate Shell");

View File

@@ -13,6 +13,7 @@ using Orchard.Tasks;
using Orchard.UI;
using Orchard.WebApi.Routes;
using Owin;
using Orchard.Exceptions;
using IModelBinderProvider = Orchard.Mvc.ModelBinders.IModelBinderProvider;
namespace Orchard.Environment {
@@ -102,8 +103,12 @@ namespace Orchard.Environment {
try {
action();
}
catch(Exception e) {
Logger.Error(e, "An unexcepted error occured while terminating the Shell");
catch(Exception ex) {
if (ex.IsFatal()) {
throw;
}
Logger.Error(ex, "An unexcepted error occured while terminating the Shell");
}
}
}

View File

@@ -8,6 +8,7 @@ using Orchard.FileSystems.Dependencies;
using Orchard.FileSystems.VirtualPath;
using Orchard.Localization;
using Orchard.Logging;
using Orchard.Exceptions;
namespace Orchard.Environment.Extensions.Compilers {
/// <summary>
@@ -106,10 +107,13 @@ namespace Orchard.Environment.Extensions.Compilers {
}
}
}
catch (Exception e) {
catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
//Note: we need to embed the "e.Message" in the exception text because
// ASP.NET build manager "swallows" inner exceptions from this method.
throw new OrchardCoreException(T("Error compiling module \"{0}\" from file \"{1}\":\r\n{2}", moduleName, context.VirtualPath, e.Message), e);
throw new OrchardCoreException(T("Error compiling module \"{0}\" from file \"{1}\":\r\n{2}", moduleName, context.VirtualPath, ex.Message), ex);
}
}

View File

@@ -9,6 +9,7 @@ using Orchard.Localization;
using Orchard.Logging;
using Orchard.Utility;
using Orchard.Utility.Extensions;
using Orchard.Exceptions;
namespace Orchard.Environment.Extensions {
public class ExtensionManager : IExtensionManager {
@@ -119,6 +120,9 @@ namespace Orchard.Environment.Extensions {
});
}
catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
Logger.Error(ex, "Error loading extension '{0}'", extensionId);
throw new OrchardException(T("Error while loading extension '{0}'.", extensionId), ex);
}

View File

@@ -8,6 +8,7 @@ using Orchard.FileSystems.WebSite;
using Orchard.Localization;
using Orchard.Logging;
using Orchard.Utility.Extensions;
using Orchard.Exceptions;
namespace Orchard.Environment.Extensions.Folders {
public class ExtensionHarvester : IExtensionHarvester {
@@ -98,6 +99,9 @@ namespace Orchard.Environment.Extensions.Folders {
}
catch (Exception ex) {
// Ignore invalid module manifests
if (ex.IsFatal()) {
throw;
}
Logger.Error(ex, "The module '{0}' could not be loaded. It was ignored.", extensionId);
_criticalErrorProvider.RegisterErrorMessage(T("The extension '{0}' manifest could not be loaded. It was ignored.", extensionId));
}

View File

@@ -4,6 +4,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Orchard.Logging;
using Orchard.Exceptions;
namespace Orchard.Environment {
public interface IAssemblyLoader {
@@ -25,8 +27,11 @@ namespace Orchard.Environment {
try {
return _loadedAssemblies.GetOrAdd(this.ExtractAssemblyShortName(assemblyName), shortName => LoadWorker(shortName, assemblyName));
}
catch (Exception e) {
Logger.Error(e, "Error loading assembly '{0}'", assemblyName);
catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
Logger.Error(ex, "Error loading assembly '{0}'", assemblyName);
return null;
}
}

View File

@@ -53,8 +53,9 @@ namespace Orchard.Environment {
return BuildManager.GetCompiledAssembly(virtualPath);
}
catch (Exception ex) {
if (ex.IsFatal()) throw;
if (ex.IsFatal()) {
throw;
}
Logger.Warning(ex, "Error when compiling assembly under {0}.", virtualPath);
return null;
}

View File

@@ -5,6 +5,7 @@ using Orchard.Environment.Descriptor;
using Orchard.Environment.Descriptor.Models;
using Orchard.FileSystems.AppData;
using Orchard.Logging;
using Orchard.Exceptions;
namespace Orchard.Environment {
public interface IHostLocalRestart {
@@ -45,8 +46,11 @@ namespace Orchard.Environment {
try {
_appDataFolder.CreateFile(fileName, "Host Restart");
}
catch(Exception e) {
Logger.Warning(e, "Error updating file '{0}'", fileName);
catch(Exception ex) {
if (ex.IsFatal()) {
throw;
}
Logger.Warning(ex, "Error updating file '{0}'", fileName);
}
}
}

View File

@@ -6,6 +6,7 @@ using System.Timers;
using System.Web.Compilation;
using Orchard.FileSystems.VirtualPath;
using Orchard.Logging;
using Orchard.Exceptions;
namespace Orchard.Environment {
public interface IViewsBackgroundCompilation {
@@ -136,10 +137,13 @@ namespace Orchard.Environment {
if (firstFile != null)
BuildManager.GetCompiledAssembly(firstFile);
}
catch(Exception e) {
catch(Exception ex) {
if (ex.IsFatal()) {
throw;
}
// Some views might not compile, this is ok and harmless in this
// context of pre-compiling views.
Logger.Information(e, "Compilation of directory '{0}' skipped", viewDirectory);
Logger.Information(ex, "Compilation of directory '{0}' skipped", viewDirectory);
}
stopwatch.Stop();
Logger.Information("Directory '{0}' compiled in {1} msec", viewDirectory, stopwatch.ElapsedMilliseconds);

View File

@@ -7,6 +7,7 @@ using System.Reflection;
using Autofac.Features.Indexed;
using Orchard.Exceptions;
using Orchard.Localization;
using Orchard.Exceptions;
namespace Orchard.Events {
public class DefaultOrchardEventBus : IEventBus {
@@ -53,6 +54,9 @@ namespace Orchard.Events {
return TryInvoke(eventHandler, messageName, interfaceName, methodName, eventData, out returnValue);
}
catch (Exception exception) {
if (exception.IsFatal()) {
throw;
}
if (!_exceptionPolicy.HandleException(this, exception)) {
throw;
}

View File

@@ -7,6 +7,7 @@ using Orchard.FileSystems.VirtualPath;
using Orchard.Localization;
using Orchard.Logging;
using Orchard.Validation;
using Orchard.Exceptions;
namespace Orchard.FileSystems.AppData {
public class AppDataFolder : IAppDataFolder {
@@ -78,8 +79,11 @@ namespace Orchard.FileSystems.AppData {
try {
File.Delete(destinationFileName);
}
catch (Exception e) {
throw new OrchardCoreException(T("Unable to make room for file \"{0}\" in \"App_Data\" folder", destinationFileName), e);
catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
throw new OrchardCoreException(T("Unable to make room for file \"{0}\" in \"App_Data\" folder", destinationFileName), ex);
}
}

View File

@@ -5,6 +5,7 @@ using System.Xml.Linq;
using Orchard.Caching;
using Orchard.FileSystems.AppData;
using Orchard.Logging;
using Orchard.Exceptions;
namespace Orchard.FileSystems.Dependencies {
/// <summary>
@@ -135,8 +136,11 @@ namespace Orchard.FileSystems.Dependencies {
return XDocument.Load(stream);
}
}
catch (Exception e) {
Logger.Information(e, "Error reading file '{0}'. Assuming empty.", persistancePath);
catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
Logger.Information(ex, "Error reading file '{0}'. Assuming empty.", persistancePath);
return new XDocument();
}
}

View File

@@ -6,6 +6,7 @@ using System.Web.Hosting;
using Orchard.Environment.Configuration;
using Orchard.Localization;
using Orchard.Validation;
using Orchard.Exceptions;
namespace Orchard.FileSystems.Media {
public class FileSystemStorageProvider : IStorageProvider {
@@ -155,6 +156,9 @@ namespace Orchard.FileSystems.Media {
directoryInfo.Create();
}
catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
throw new ArgumentException(T("The folder could not be created at path: {0}. {1}", path, ex).ToString());
}
}

View File

@@ -5,6 +5,7 @@ using System.Linq;
using System.Web;
using System.Web.Hosting;
using Orchard.Logging;
using Orchard.Exceptions;
namespace Orchard.FileSystems.VirtualPath {
public class DefaultVirtualPathProvider : IVirtualPathProvider {
@@ -59,9 +60,12 @@ namespace Orchard.FileSystems.VirtualPath {
}
return result;
}
catch (Exception e) {
catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
// The initial path might have been invalid (e.g. path indicates a path outside the application root)
Logger.Information(e, "Path '{0}' cannot be made app relative", virtualPath);
Logger.Information(ex, "Path '{0}' cannot be made app relative", virtualPath);
return null;
}
}
@@ -156,8 +160,11 @@ namespace Orchard.FileSystems.VirtualPath {
try {
return FileExists(virtualPath);
}
catch (Exception e) {
Logger.Information(e, "File '{0}' can not be checked for existence. Assuming doesn't exist.", virtualPath);
catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
Logger.Information(ex, "File '{0}' can not be checked for existence. Assuming doesn't exist.", virtualPath);
return false;
}
}

View File

@@ -5,6 +5,7 @@ using Orchard.Logging;
using Orchard.Messaging.Events;
using Orchard.Messaging.Models;
using Orchard.ContentManagement.Records;
using Orchard.Exceptions;
namespace Orchard.Messaging.Services {
[Obsolete]
@@ -40,8 +41,11 @@ namespace Orchard.Messaging.Services {
PrepareAndSend(type, properties, context);
}
catch ( Exception e ) {
Logger.Error(e, "An error occured while sending the message {0}", type);
catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
Logger.Error(ex, "An error occured while sending the message {0}", type);
}
}
@@ -60,8 +64,11 @@ namespace Orchard.Messaging.Services {
PrepareAndSend(type, properties, context);
}
catch (Exception e) {
Logger.Error(e, "An error occured while sending the message {0}", type);
catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
Logger.Error(ex, "An error occured while sending the message {0}", type);
}
}

View File

@@ -11,6 +11,7 @@ using System.Web.Routing;
using Autofac;
using Orchard.Mvc.Routes;
using Orchard.Settings;
using Orchard.Exceptions;
namespace Orchard.Mvc {
public class MvcModule : Module {
@@ -31,7 +32,11 @@ namespace Orchard.Mvc {
// The "Request" property throws at application startup on IIS integrated pipeline mode.
var req = HttpContext.Current.Request;
}
catch (Exception) {
catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
return false;
}

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using Orchard.Data;
using Orchard.Environment.Configuration;
using Orchard.Logging;
using Orchard.Exceptions;
namespace Orchard.Tasks {
@@ -39,9 +40,13 @@ namespace Orchard.Tasks {
task.Sweep();
Logger.Information("Finished processing background task \"{0}\" on tenant \"{1}\".", taskName, _shellName);
}
catch (Exception e) {
catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
_transactionManager.Cancel();
Logger.Error(e, "Error while processing background task \"{0}\" on tenant \"{1}\".", taskName, _shellName);
Logger.Error(ex, "Error while processing background task \"{0}\" on tenant \"{1}\".", taskName, _shellName);
}
}
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Timers;
using Orchard.Logging;
using Orchard.Exceptions;
namespace Orchard.Tasks {
@@ -51,6 +52,10 @@ namespace Orchard.Tasks {
}
}
catch (Exception ex) {
if (ex.IsFatal()) {
throw;
}
Logger.Warning(ex, "Problem in background tasks");
}
finally {

View File

@@ -1,6 +1,7 @@
using System;
using System.Web;
using Orchard.Logging;
using Orchard.Exceptions;
namespace Orchard.Time {
/// <summary>
@@ -31,8 +32,11 @@ namespace Orchard.Time {
TimeZone = TimeZoneInfo.FindSystemTimeZoneById(siteTimeZoneId)
};
}
catch(Exception e) {
Logger.Error(e, "TimeZone could not be loaded");
catch(Exception ex) {
if (ex.IsFatal()) {
throw;
}
Logger.Error(ex, "TimeZone could not be loaded");
// if the database could not be updated in time, ignore this provider
return null;

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using Orchard.Logging;
using Orchard.UI.Notify;
using Orchard.Exceptions;
namespace Orchard.UI.Admin.Notification {
public class NotificationManager : INotificationManager {
@@ -22,8 +23,11 @@ namespace Orchard.UI.Admin.Notification {
try {
return n.GetNotifications();
}
catch(Exception e) {
Logger.Error("An unhandled exception was thrown while generating a notification: " + n.GetType(), e);
catch(Exception ex) {
if (ex.IsFatal()) {
throw;
}
Logger.Error("An unhandled exception was thrown while generating a notification: " + n.GetType(), ex);
return Enumerable.Empty<NotifyEntry>();
}
}).ToList();