~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Parser.Internal/ParseException.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//
2
 
// System.Web.Compilation.ParseException
3
 
//
4
 
// Authors:
5
 
//      Gonzalo Paniagua Javier (gonzalo@ximian.com)
6
 
//
7
 
// (C) 2003 Ximian, Inc (http://www.ximian.com)
8
 
//
9
 
 
10
 
//
11
 
// Permission is hereby granted, free of charge, to any person obtaining
12
 
// a copy of this software and associated documentation files (the
13
 
// "Software"), to deal in the Software without restriction, including
14
 
// without limitation the rights to use, copy, modify, merge, publish,
15
 
// distribute, sublicense, and/or sell copies of the Software, and to
16
 
// permit persons to whom the Software is furnished to do so, subject to
17
 
// the following conditions:
18
 
// 
19
 
// The above copyright notice and this permission notice shall be
20
 
// included in all copies or substantial portions of the Software.
21
 
// 
22
 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23
 
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24
 
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25
 
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26
 
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27
 
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28
 
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
 
//
30
 
 
31
 
using System;
32
 
using System.IO;
33
 
using MonoDevelop.AspNet.Parser.Dom;
34
 
 
35
 
namespace MonoDevelop.AspNet.Parser.Internal
36
 
{
37
 
        public class ParseException : HtmlizedException
38
 
        {
39
 
                ILocation location;
40
 
                string fileText;
41
 
 
42
 
                public ParseException (ILocation location, string message)
43
 
                        : this (location, message, null)
44
 
                {
45
 
                }
46
 
 
47
 
 
48
 
                public ParseException (ILocation location, string message, Exception inner)
49
 
                        : base (message, inner)
50
 
                {
51
 
                        this.location = new Location (location);
52
 
                }
53
 
 
54
 
                public override string Title {
55
 
                        get { return "Parser Error"; }
56
 
                }
57
 
 
58
 
                public override string Description {
59
 
                        get {
60
 
                                return "Error parsing a resource required to service this request. " +
61
 
                                       "Review your source file and modify it to fix this error.";
62
 
                        }
63
 
                }
64
 
                
65
 
                public ILocation Location {
66
 
                        get { return location; }
67
 
                }
68
 
 
69
 
                public override string ErrorMessage {
70
 
                        get { return Message; }
71
 
                }
72
 
 
73
 
                public override string SourceFile {
74
 
                        get { return FileName; }
75
 
                }
76
 
                
77
 
                public override string FileName {
78
 
                        get {
79
 
                                if (location == null)
80
 
                                        return null;
81
 
 
82
 
                                return location.Filename;
83
 
                        }
84
 
                }
85
 
 
86
 
                public override string FileText {
87
 
                        get {
88
 
                                if (fileText != null)
89
 
                                        return fileText;
90
 
 
91
 
                                string text = location != null ? location.FileText : null;
92
 
                                if (text != null && text.Length > 0)
93
 
                                        return text;
94
 
                                
95
 
                                if (FileName == null)
96
 
                                        return null;
97
 
 
98
 
                                //FIXME: encoding
99
 
                                using (TextReader reader = new StreamReader (FileName))
100
 
                                        fileText = reader.ReadToEnd ();
101
 
                                return fileText;
102
 
                        }
103
 
                }
104
 
 
105
 
                public override int [] ErrorLines {
106
 
                        get {
107
 
                                if (location == null)
108
 
                                        return null;
109
 
 
110
 
                                return new int [] {location.BeginLine, location.EndLine};
111
 
                        }
112
 
                }
113
 
 
114
 
                public override bool ErrorLinesPaired {
115
 
                        get { return true; }
116
 
                }
117
 
        }
118
 
 
119
 
        public abstract class HtmlizedException : Exception
120
 
        {
121
 
                protected HtmlizedException ()
122
 
                {
123
 
                }
124
 
 
125
 
                protected HtmlizedException (string message)
126
 
                        : base (message)
127
 
                {
128
 
                }
129
 
 
130
 
                protected HtmlizedException (string message, Exception inner)
131
 
                        : base (message, inner)
132
 
                {
133
 
                }
134
 
 
135
 
                public abstract string Title { get; }
136
 
                public abstract string Description { get; }
137
 
                public abstract string ErrorMessage { get; }
138
 
                public abstract string FileName { get; }
139
 
                public abstract string SourceFile { get; }
140
 
                public abstract string FileText { get; }
141
 
                public abstract int [] ErrorLines { get; }
142
 
                public abstract bool ErrorLinesPaired { get; }
143
 
        }
144
 
 
145
 
}
146