public void Process(ExecutionContext context) { Branch branch = context.Store.Current; if (branch.IsRemote) { branch = branch.CreateLocal(context); } var cmd = context.CreateCmdData(CmdName); cmd.Add(nameof(AddCmdLine.Name), Name); // Update relevant model(s) if (context.Apply(cmd)) { branch.SaveData(cmd); } else { ProcessorException pex = context.LastProcessingError; if (pex == null) { Console.WriteLine("Handler failed"); } else { ShowError(pex); } } }
protected HttpException CreateRenderException(ProcessorException ex) { var sb = new StringBuilder(); if (ex.ErrorCode != null && !ex.ErrorCode.IsEmpty) { sb.Append("(") .Append(ex.ErrorCode.ToString()) .Append(") "); } sb.Append(ex.Message); if (ex.ModuleUri != null) { sb.AppendLine() .Append("URI: ") .Append(ex.ModuleUri.ToString()) .AppendLine() .Append("Line number: ") .Append(ex.LineNumber.ToString(CultureInfo.InvariantCulture)); } return(new HttpException((int)HttpStatusCode.InternalServerError, sb.ToString(), ex)); }
/// <summary> /// Executes the processor with the given request. Parameterized <see cref="ProcessAsync(TRequest)"/> is used /// to execute with a given request TRequest> /// </summary> /// <param name="request">The request to be executed</param> /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> public async Task ProcessAsync() { ProcessorException processorException = null; try { this.SetRequest(); await this.ValidateAsync(); await this.PreProcessAsync(); await this.ProcessCoreAsync(); this.Response = await this.PostProcessAsync(); await this.OnProcessCompletedAsync(); } catch (Exception exception) { this.Logger.LogError(exception, this.Name); processorException = new ProcessorException("Request processesing failed", exception); } finally { if (null != processorException) { await this.OnProcessFailedAsync(processorException); } } }
protected Exception CreateCompileException(ProcessorException exception) { string localPath = this.PhysicalPath.LocalPath; string virtualPath = this.VirtualPath; int lineNumber = exception.LineNumber; string errorCode = exception.GetErrorCodeAsClarkName(); string message = exception.Message; if (exception.ModuleUri != null && exception.ModuleUri.IsFile && exception.ModuleUri != this.PhysicalPath) { localPath = exception.ModuleUri.LocalPath; Uri diff = this.ApplicationPhysicalPath.MakeRelativeUri(exception.ModuleUri); string diffString = diff.ToString(); if (!diffString.StartsWith("..", StringComparison.Ordinal)) { virtualPath = "/" + diffString; } } return(CreateCompileException(message, errorCode, lineNumber, localPath, virtualPath)); }
protected Exception CreateCompileException (ProcessorException exception) { string localPath = this.PhysicalPath.LocalPath; string virtualPath = this.VirtualPath; int lineNumber = exception.LineNumber; string errorCode = exception.GetErrorCodeAsClarkName (); string message = exception.Message; if (exception.ModuleUri != null && exception.ModuleUri.IsFile && exception.ModuleUri != this.PhysicalPath) { localPath = exception.ModuleUri.LocalPath; Uri diff = this.ApplicationPhysicalPath.MakeRelativeUri (exception.ModuleUri); string diffString = diff.ToString (); if (!diffString.StartsWith ("..")) virtualPath = "/" + diffString; } return CreateCompileException (message, errorCode, lineNumber, localPath, virtualPath); }
/// <summary> /// Any notifications or tasks that need to be executed when execution is failed /// </summary> /// <param name="executionException"></param> ///// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> protected virtual async Task OnProcessFailedAsync(ProcessorException executionException) => await Task.FromResult(true);
/// <summary> /// If any process step failed, framex calls /// <see cref="BaseProcessor{TRequest, TResponse}.OnProcessFailedAsync"/>. /// For example, build any code that sends alert emails if any operation fails /// in the above steps. /// <param name="processException"></param> /// <returns></returns> /// </summary> protected override Task OnProcessFailedAsync(ProcessorException processException) { return(base.OnProcessFailedAsync(processException)); }