/// <summary> /// UI Unhandled Exception Handler /// </summary> /// <param name="exception"></param> public Exception UIExceptionHandler(Exception exception) { ControllerConfigurator.utilityProvider.GetLogger().LogFatal("Executor.ExecuteProcess", exception); JsonException jsonException = ExceptionBag.Get(Constants.WEB_UNHANDLED_EXCEPTIONID.ToString()) as JsonException; jsonException.ErrorData = exception.Message; throw jsonException; }
public static void Configure(string configXMLFile) { string fileName = AppDomain.CurrentDomain.BaseDirectory + configXMLFile; if (!File.Exists(fileName)) { throw new FileNotFoundException(fileName); } XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(fileName); XmlNodeList frameworkException = xmlDocument.SelectNodes(@"//Exceptions/Exception"); foreach (XmlNode exceptionDetails in frameworkException) { IExceptionConfig exceptionConfig = null; string resultType = exceptionDetails.SelectSingleNode("Response").Attributes["Type"].Value; if (Enum.GetName(typeof(ResultType), ResultType.JSON) == resultType) { exceptionConfig = new JsonException(); if (exceptionConfig.ResponseType == ResultType.JSON) { XmlNode jsonDetails = exceptionDetails.SelectSingleNode("Json"); ((JsonException)exceptionConfig).Type = (DisplayType)Int16.Parse(jsonDetails.Attributes["Type"].Value); if (jsonDetails.ChildNodes.Count > 0) { ((JsonException)exceptionConfig).ActionConfig = new List <ExceptionActionConfig>(); foreach (XmlNode exceptionCommand in jsonDetails) { ExceptionActionConfig actionConfig = new ExceptionActionConfig(); string commandName = exceptionCommand.Attributes["Name"].Value; actionConfig.Name = commandName;// To get Externalized String actionConfig.URI = exceptionCommand.Attributes["URI"].Value; actionConfig.Function = exceptionCommand.Attributes["Function"].Value; ((JsonException)exceptionConfig).ActionConfig.Add(actionConfig); } } } } else { exceptionConfig = new ViewException(); XmlNode viewDetails = exceptionDetails.SelectSingleNode("View"); ((ViewException)exceptionConfig).ViewName = viewDetails.Attributes["Name"].Value; } exceptionConfig.ErrorId = Int64.Parse(exceptionDetails.Attributes["Id"].Value); ExceptionBag.Add(exceptionConfig.ErrorId, exceptionConfig); } }
private IController GetExceptionController(FrameworkException exception, ExecutionContext executionContext, ISessionContext sessionContext) { System.Web.Mvc.Controller controller = null; IExceptionConfig exceptionConfig = ExceptionBag.Get(exception.ErrorId.ToString()); object command = Activator.CreateInstance(typeof(HandledExceptionCommand), exception); object resultBuilder = ActionResultBuilderFactory.Create(exceptionConfig.ResponseType, null); Type controllerType = typeof(Requestor <,>).MakeGenericType( new Type[] { typeof(HandledExceptionCommand), typeof(JsonErrorMessage) }); ISafeBlockProvider safeBlockProvider = ControllerConfigurator.utilityProvider.GetSafeBlockProvider(); executionContext.SafeActionBlock = safeBlockProvider.Create("UIDefault"); controller = Activator.CreateInstance(controllerType, executionContext, sessionContext, command, resultBuilder) as System.Web.Mvc.Controller; return(controller); }
/// <summary> /// Module Exception Handler /// </summary> /// <param name="exception"></param> public virtual Exception ExceptionHandler(Exception exception) { string errorMSG = ControllerConfigurator.iResourceService.GetLiteral((exception as ModuleException).ErrorCode.ToString()); IExceptionConfig exceptionConfig = ExceptionBag.Get((exception as ModuleException).ErrorCode.ToString()); if (exceptionConfig.ResponseType == ResultType.JSON) { exceptionConfig.ErrorData = exception.Message; return(exceptionConfig as JsonException); } else { return(exceptionConfig as ViewException); } }
public override JsonErrorMessage Get(IExecutionContext executionCtx, ISessionContext sessionCtx) { executionCtx.ResponseHeader.Add(Constants.EXCEPTIONHEADER, "JSON"); if (frameworkException != null) { IExceptionConfig exceptionConfig = ExceptionBag.Get(frameworkException.ErrorId.ToString()); JsonErrorMessage exceptionMessage = new JsonErrorMessage() { Message = frameworkException.ErrorMessage, ActionCommand = (exceptionConfig as JsonException).ActionConfig }; return(exceptionMessage); } else { throw new System.Exception("Exception Configuration not found"); } }