2 // JScriptException.cs:
5 // Cesar Lopez Nataren (cesar@ciencias.unam.mx)
7 // (C) 2003, Cesar Lopez Nataren
8 // (C) 2005, Novell Inc, (http://novell.com)
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 using System.Runtime.Serialization;
37 namespace Microsoft.JScript {
40 public class JScriptException : ApplicationException, IVsaError {
42 private JSError error_number;
43 private string user_error = null;
44 private string extra_data = "";
46 public JScriptException (JSError errorNumber)
48 error_number = errorNumber;
51 internal JScriptException (JSError errorNumber, string extraData)
53 error_number = errorNumber;
54 extra_data = extraData;
57 internal JScriptException (string user_err)
59 error_number = JSError.NoError;
60 user_error = user_err;
63 public string SourceMoniker {
64 get { throw new NotImplementedException (); }
68 public int StartColumn {
69 get { throw new NotImplementedException (); }
74 get { throw new NotImplementedException (); }
78 public string Description {
80 if (error_number == JSError.NoError)
82 else if (error_number == JSError.ArrayLengthConstructIncorrect)
83 return "Array length must be zero or a positive integer";
84 else if (error_number == JSError.PrecisionOutOfRange)
85 return "The number of fractional digits is out of range";
86 else if (error_number == JSError.RegExpSyntax)
87 return "Syntax error in regular expression";
88 else if (error_number == JSError.TypeMismatch)
89 return "Unexpected type";
90 else if (error_number == JSError.BooleanExpected)
91 return "Invoked Boolean.prototype.toString or Boolean.prototype.valueOf method on non-boolean";
92 else if (error_number == JSError.NumberExpected)
93 return "Invoked Number.prototype.toString or Number.prototype.valueOf method on non-number";
94 else if (error_number == JSError.StringExpected)
95 return "Invoked String.prototype.toString or String.prototype.valueOf method on non-string";
96 else if (error_number == JSError.FunctionExpected)
97 return "Invoked Function.prototype.toString on non-function";
98 else if (error_number == JSError.AssignmentToReadOnly)
99 return "Tried to assign to read only property";
101 Console.WriteLine ("JScriptException:get_Message: unknown error_number {0}", error_number);
102 throw new NotImplementedException ();
109 get { throw new NotImplementedException (); }
113 public int EndColumn {
114 get { throw new NotImplementedException (); }
119 get { return (int) error_number; }
123 public int ErrorNumber {
124 get { return (int) error_number; }
128 public override void GetObjectData (SerializationInfo info, StreamingContext context)
130 throw new NotImplementedException ();
135 get { throw new NotImplementedException (); }
139 public string LineText {
140 get { throw new NotImplementedException (); }
144 public override string Message {
147 StringBuilder result = new StringBuilder (Description);
148 if (extra_data != "") {
149 result.Append (": ");
150 result.Append (extra_data);
152 return result.ToString ();
157 public int Severity {
158 get { throw new NotImplementedException (); }
162 public IVsaItem SourceItem {
163 get { throw new NotImplementedException (); }
167 public override string StackTrace {
169 return base.StackTrace;
175 public class NoContextException : ApplicationException