/// <summary> /// Handles any exception occurred in the module Initialization process, /// This method can be overridden to provide a different behavior. /// </summary> /// <param name="moduleInfo">The module metadata where the error happened.</param> /// <param name="assemblyName">The assembly name.</param> /// <param name="exception">The exception thrown that is the cause of the current error.</param> /// <exception cref="ModuleInitializeException"></exception> public virtual void HandleModuleInitializationError(IModuleInfo moduleInfo, string assemblyName, Exception exception) { if (moduleInfo == null) { throw new ArgumentNullException(nameof(moduleInfo)); } if (exception == null) { throw new ArgumentNullException(nameof(exception)); } Exception moduleException; if (exception is ModuleInitializeException) { moduleException = exception; } else { if (!string.IsNullOrEmpty(assemblyName)) { moduleException = new ModuleInitializeException(moduleInfo.ModuleName, assemblyName, exception.Message, exception); } else { moduleException = new ModuleInitializeException(moduleInfo.ModuleName, exception.Message, exception); } } throw moduleException; }
/// <summary> /// Handles any exception occurred in the module Initialization process, /// logs the error using the <see cref="ILoggerFacade"/> and throws a <see cref="ModuleInitializeException"/>. /// This method can be overridden to provide a different behavior. /// </summary> /// <param name="moduleInfo">The module metadata where the error happenened.</param> /// <param name="assemblyName">The assembly name.</param> /// <param name="exception">The exception thrown that is the cause of the current error.</param> /// <exception cref="ModuleInitializeException"></exception> public virtual void HandleModuleInitializationError(ModuleInfo moduleInfo, string assemblyName, Exception exception) { if (moduleInfo == null) { throw new ArgumentNullException(nameof(moduleInfo)); } if (exception == null) { throw new ArgumentNullException(nameof(exception)); } Exception moduleException; if (exception is ModuleInitializeException) { moduleException = exception; } else { if (!string.IsNullOrEmpty(assemblyName)) { moduleException = new ModuleInitializeException(moduleInfo.ModuleName, assemblyName, exception.Message, exception); } else { moduleException = new ModuleInitializeException(moduleInfo.ModuleName, exception.Message, exception); } } this.loggerFacade.Log(moduleException.ToString(), Category.Exception, Priority.High); throw moduleException; }
/// <summary> /// Handles any exception occurred in the module Initialization process, /// logs the error using the <see cref="ILoggerFacade"/> and throws a <see cref="ModuleInitializeException"/>. /// This method can be overridden to provide a different behavior. /// </summary> /// <param name="moduleInfo">The module metadata where the error happenened.</param> /// <param name="assemblyName">The assembly name.</param> /// <param name="exception">The exception thrown that is the cause of the current error.</param> /// <exception cref="ModuleInitializeException"></exception> public virtual void HandleModuleInitializationError(ModuleInfo moduleInfo, string assemblyName, Exception exception) { if (moduleInfo == null) throw new ArgumentNullException("moduleInfo"); if (exception == null) throw new ArgumentNullException("exception"); Exception moduleException; if (exception is ModuleInitializeException) { moduleException = exception; } else { if (!string.IsNullOrEmpty(assemblyName)) { moduleException = new ModuleInitializeException(moduleInfo.ModuleName, assemblyName, exception.Message, exception); } else { moduleException = new ModuleInitializeException(moduleInfo.ModuleName, exception.Message, exception); } } this.loggerFacade.Log(moduleException.ToString(), Category.Exception, Priority.High); throw moduleException; }