public ActionResult BuildException(IExceptionConfig exceptionConfig) { JsonErrorMessage exceptionMessage = new JsonErrorMessage() { Message = (exceptionConfig as JsonException).ErrorData.ToString(), ActionCommand = (exceptionConfig as JsonException).ActionConfig }; IActionResultBuilder resultBuilder = ActionResultBuilderFactory.Create(ResponseType, null); return resultBuilder.Build(exceptionMessage); }
public void RegisterExceptionConfig(IExceptionConfig config) { _config?.UnregisterManager(this); _config = config; _config?.RegisterManager(this); }
public ActionResult BuildException(IExceptionConfig exceptionConfig) { string viewName = ((ViewException)exceptionConfig).ViewName; IActionResultBuilder resultBuilder = ActionResultBuilderFactory.Create(exceptionConfig.ResponseType, viewName); return(resultBuilder.Build(exceptionConfig.ErrorData)); }
public static ActionResult HandleException(FrameworkException frameworkException, IExecutionContext executionCtx, ISessionContext sessionCtx) { IExceptionConfig expConfig = ExceptionBag.Get(frameworkException.ErrorId.ToString()); IActionResultBuilder exceptionBuilder = ActionResultBuilderFactory.Create(expConfig.ResponseType, null); ExceptionCommand exceptionCommand = new ExceptionCommand(expConfig); ExceptionViewModel exceptionModel = exceptionCommand.Get(executionCtx, sessionCtx); return(exceptionBuilder.Build(exceptionModel)); }
public ActionResult BuildException(IExceptionConfig exceptionConfig) { JsonErrorMessage exceptionMessage = new JsonErrorMessage() { Message = (exceptionConfig as JsonException).ErrorData.ToString(), ActionCommand = (exceptionConfig as JsonException).ActionConfig }; IActionResultBuilder resultBuilder = ActionResultBuilderFactory.Create(ResponseType, null); return(resultBuilder.Build(exceptionMessage)); }
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); } }
public static IExceptionConfig Get(string errorId) { IExceptionConfig exception = null; _nameExceptionParamMap.TryGetValue(Int64.Parse(errorId), out exception); if (exception == null) { exception = new JsonException(Int64.Parse(errorId)); (exception as JsonException).AddCommands("Close", "$.unblockUI", ""); } return(exception); }
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"); } }
internal static void Add(Int64 errorId, IExceptionConfig @params) { _nameExceptionParamMap.Add(errorId, @params); }
public ActionResult BuildException(IExceptionConfig exceptionConfig) { string viewName = ((ViewException)exceptionConfig).ViewName; IActionResultBuilder resultBuilder = ActionResultBuilderFactory.Create(exceptionConfig.ResponseType, viewName); return resultBuilder.Build(exceptionConfig.ErrorData); }
private async Task WriteExceptionAsync(HttpContext context, Exception exception, IExceptionConfig exceptionParams) { var response = context.Response; response.ContentType = _contentType; response.StatusCode = (int)(exceptionParams.StatusCode ?? HttpStatusCode.InternalServerError); var message = exceptionParams.Formatter(exception); await response.WriteAsync(message).ConfigureAwait(false); }
public ExceptionCommand(IExceptionConfig frameworkException) { this.frameworkException = frameworkException; }