Пример #1
0
        private void InnerPostProcess(IAsset asset, CssAutoprefixer cssAutoprefixer)
        {
            string         content = asset.Content;
            string         newContent;
            string         assetUrl = asset.Url;
            IList <string> dependencies;

            try
            {
                newContent = !string.IsNullOrWhiteSpace(content) ?
                             cssAutoprefixer.Process(content, assetUrl).ProcessedContent
                                        :
                             content ?? string.Empty
                ;
                dependencies = GetIncludedFilePaths(Stats);
            }
            catch (AutoprefixerProcessingException e)
            {
                string errorDetails = AutoprefixerErrorHelpers.GenerateErrorDetails(e, true);

                var           stringBuilderPool   = StringBuilderPool.Shared;
                StringBuilder errorMessageBuilder = stringBuilderPool.Rent();
                errorMessageBuilder.AppendLine(e.Message);
                errorMessageBuilder.AppendLine();
                errorMessageBuilder.Append(errorDetails);

                string errorMessage = errorMessageBuilder.ToString();
                stringBuilderPool.Return(errorMessageBuilder);

                throw new AssetPostProcessingException(
                          string.Format(CoreStrings.PostProcessors_PostprocessingSyntaxError,
                                        CODE_TYPE, assetUrl, POSTPROCESSOR_NAME, errorMessage));
            }
            catch (Exception e)
            {
                throw new AssetPostProcessingException(
                          string.Format(CoreStrings.PostProcessors_PostprocessingFailed,
                                        CODE_TYPE, assetUrl, POSTPROCESSOR_NAME, e.Message), e);
            }

            asset.Content = newContent;
            asset.VirtualPathDependencies = asset.VirtualPathDependencies.Union(dependencies).ToList();
        }
Пример #2
0
        /// <summary>
        /// Returns a string that represents the current exception
        /// </summary>
        /// <returns>A string that represents the current exception</returns>
        public override string ToString()
        {
            string errorDetails = AutoprefixerErrorHelpers.GenerateErrorDetails(this, true);

            var           stringBuilderPool = StringBuilderPool.Shared;
            StringBuilder resultBuilder     = stringBuilderPool.Rent();

            resultBuilder.Append(this.GetType().FullName);
            resultBuilder.Append(": ");
            resultBuilder.Append(this.Message);

            if (errorDetails.Length > 0)
            {
                resultBuilder.AppendLine();
                resultBuilder.AppendLine();
                resultBuilder.Append(errorDetails);
            }

            if (this.InnerException != null)
            {
                resultBuilder.Append(" ---> ");
                resultBuilder.Append(this.InnerException.ToString());
            }

            if (this.StackTrace != null)
            {
                resultBuilder.AppendLine();
                resultBuilder.AppendLine(this.StackTrace);
            }

            string result = resultBuilder.ToString();

            stringBuilderPool.Return(resultBuilder);

            return(result);
        }