~alexreg/mathtexdotnet/0.1

« back to all changes in this revision

Viewing changes to TexDotNet/TexExpressionTreeBuilderException.cs

  • Committer: Alex Regueiro
  • Date: 2009-09-24 01:20:38 UTC
  • Revision ID: alexreg@gmail.com-20090924012038-nhku9xfjw3iwxn5z
TexComposer and TexWriter now work correctly for test expression.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using System;
 
2
using System.Collections.Generic;
 
3
using System.Linq;
 
4
using System.Text;
 
5
 
 
6
namespace TexDotNet
 
7
{
 
8
    public class TexExpressionTreeBuilderException : Exception
 
9
    {
 
10
        private const string errorMessageInvalidSymbol =
 
11
            "Expected a parse node with one of the following symbol kinds: {0}.";
 
12
 
 
13
        public TexExpressionTreeBuilderException(ParseNode node, ICollection<TexSymbolKind> expectedSymbolKinds)
 
14
            : this(node, string.Format(errorMessageInvalidSymbol,
 
15
            string.Join(", ", expectedSymbolKinds.Select(tokenKind => tokenKind.ToString()).ToArray())))
 
16
        {
 
17
        }
 
18
 
 
19
        public TexExpressionTreeBuilderException(ParseNode node, string message)
 
20
            : base(message)
 
21
        {
 
22
            this.Node = node;
 
23
        }
 
24
 
 
25
        public ParseNode Node
 
26
        {
 
27
            get;
 
28
            private set;
 
29
        }
 
30
 
 
31
        public override string Message
 
32
        {
 
33
            get 
 
34
                { 
 
35
                        return
 
36
                    base.Message +  Environment.NewLine +
 
37
                    string.Format("Parse node: {0}", this.Node);
 
38
                }
 
39
        }
 
40
    }
 
41
}