示例#1
0
        /// <summary>
        /// Generates a detailed error message
        /// </summary>
        /// <param name="sassException">Sass exception</param>
        /// <param name="omitMessage">Flag for whether to omit message</param>
        /// <returns>Detailed error message</returns>
        public static string GenerateErrorDetails(SassException sassException, bool omitMessage = false)
        {
            if (sassException == null)
            {
                throw new ArgumentNullException(nameof(sassException));
            }

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

            WriteCommonErrorDetails(detailsBuilder, sassException, omitMessage);

            var sassСompilationException = sassException as SassCompilationException;

            if (sassСompilationException != null)
            {
                WriteCompilationErrorDetails(detailsBuilder, sassСompilationException);
            }

            detailsBuilder.TrimEnd();

            string errorDetails = detailsBuilder.ToString();

            stringBuilderPool.Return(detailsBuilder);

            return(errorDetails);
        }
示例#2
0
 /// <summary>
 /// Writes a detailed error message to the buffer
 /// </summary>
 /// <param name="buffer">Instance of <see cref="StringBuilder"/></param>
 /// <param name="sassException">Sass exception</param>
 /// <param name="omitMessage">Flag for whether to omit message</param>
 private static void WriteCommonErrorDetails(StringBuilder buffer, SassException sassException,
                                             bool omitMessage = false)
 {
     if (!omitMessage)
     {
         buffer.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_Message,
                                 sassException.Message);
     }
 }
        private static void WriteError(string title, SassException exception)
        {
            Console.WriteLine("{0} See details:", title);
            Console.WriteLine();
            Console.Write(exception.Message);

            string errorDetails = SassErrorHelpers.GenerateErrorDetails(exception, true);

            if (errorDetails.Length > 0)
            {
                Console.WriteLine();
                Console.WriteLine();
                Console.Write(errorDetails);
            }

            Console.WriteLine();
            Console.WriteLine();
        }
示例#4
0
 public static string Format(SassException sassException)
 {
     return(GenerateErrorDetails(sassException));
 }