Exemplo n.º 1
0
        /// <summary>
        /// Generates a detailed error message
        /// </summary>
        /// <param name="autoprefixerException">Autoprefixer exception</param>
        /// <param name="omitMessage">Flag for whether to omit message</param>
        /// <returns>Detailed error message</returns>
        public static string GenerateErrorDetails(AutoprefixerException autoprefixerException, bool omitMessage = false)
        {
            if (autoprefixerException == null)
            {
                throw new ArgumentNullException(nameof(autoprefixerException));
            }

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

            WriteCommonErrorDetails(detailsBuilder, autoprefixerException, omitMessage);

            var autoprefixerProcessingException = autoprefixerException as AutoprefixerProcessingException;

            if (autoprefixerProcessingException != null)
            {
                WriteProcessingErrorDetails(detailsBuilder, autoprefixerProcessingException);
            }

            detailsBuilder.TrimEnd();

            string errorDetails = detailsBuilder.ToString();

            stringBuilderPool.Return(detailsBuilder);

            return(errorDetails);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Writes a detailed error message to the buffer
 /// </summary>
 /// <param name="buffer">Instance of <see cref="StringBuilder"/></param>
 /// <param name="autoprefixerException">Autoprefixer exception</param>
 /// <param name="omitMessage">Flag for whether to omit message</param>
 private static void WriteCommonErrorDetails(StringBuilder buffer,
                                             AutoprefixerException autoprefixerException, bool omitMessage = false)
 {
     if (!omitMessage)
     {
         buffer.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_Message,
                                 autoprefixerException.Message);
     }
 }