@@ -84,9 +84,15 @@ local SystemException = define("System.SystemException", {
8484local ArgumentException = define (" System.ArgumentException" , {
8585 __tostring = toString ,
8686 __inherits__ = { SystemException },
87- __ctor__ = function (this , message , paramName , innerException )
87+ __ctor__ = function (this , message , paramName , innerException )
88+ if type (paramName ) == " table" then
89+ paramName , innerException = nil , paramName
90+ end
8891 ctorOfException (this , message or " Value does not fall within the expected range." , innerException )
8992 this .paramName = paramName
93+ if paramName and # paramName > 0 then
94+ this .message = this .message .. " \n Parameter name: " .. paramName
95+ end
9096 end ,
9197 getParamName = function (this )
9298 return this .paramName
@@ -97,27 +103,15 @@ define("System.ArgumentNullException", {
97103 __tostring = toString ,
98104 __inherits__ = { ArgumentException },
99105 __ctor__ = function (this , paramName , message , innerException )
100- if not message then
101- message = " Value cannot be null."
102- if paramName then
103- message = message .. " \n Parameter name: " .. paramName
104- end
105- end
106- ArgumentException .__ctor__ (this , message , paramName , innerException )
106+ ArgumentException .__ctor__ (this , message or " Value cannot be null." , paramName , innerException )
107107 end
108108})
109109
110110define (" System.ArgumentOutOfRangeException" , {
111111 __tostring = toString ,
112112 __inherits__ = { ArgumentException },
113113 __ctor__ = function (this , paramName , message , innerException , actualValue )
114- if not message then
115- message = " Value is out of range."
116- if paramName then
117- message = message .. " \n Parameter name = " .. paramName
118- end
119- end
120- ArgumentException .__ctor__ (this , message , paramName , innerException )
114+ ArgumentException .__ctor__ (this , message or " Specified argument was out of the range of valid values." , paramName , innerException )
121115 this .actualValue = actualValue
122116 end ,
123117 getActualValue = function (this )
@@ -127,7 +121,7 @@ define("System.ArgumentOutOfRangeException", {
127121
128122define (" System.IndexOutOfRangeException" , {
129123 __tostring = toString ,
130- __inherits__ = { Exception },
124+ __inherits__ = { SystemException },
131125 __ctor__ = function (this , message , innerException )
132126 ctorOfException (this , message or " Index was outside the bounds of the array." , innerException )
133127 end
@@ -158,17 +152,18 @@ define("System.CultureNotFoundException", {
158152 end
159153})
160154
161- define (" System.KeyNotFoundException" , {
155+ local KeyNotFoundException = define (" System.Collections.Generic .KeyNotFoundException" , {
162156 __tostring = toString ,
163- __inherits__ = { Exception },
157+ __inherits__ = { SystemException },
164158 __ctor__ = function (this , message , innerException )
165- ctorOfException (this , message or " Key not found ." , innerException )
159+ ctorOfException (this , message or " The given key was not present in the dictionary ." , innerException )
166160 end
167161})
162+ System .KeyNotFoundException = KeyNotFoundException
168163
169164local ArithmeticException = define (" System.ArithmeticException" , {
170165 __tostring = toString ,
171- __inherits__ = { Exception },
166+ __inherits__ = { SystemException },
172167 __ctor__ = function (this , message , innerException )
173168 ctorOfException (this , message or " Overflow or underflow in the arithmetic operation." , innerException )
174169 end
@@ -178,7 +173,7 @@ define("System.DivideByZeroException", {
178173 __tostring = toString ,
179174 __inherits__ = { ArithmeticException },
180175 __ctor__ = function (this , message , innerException )
181- ArithmeticException .__ctor__ (this , message or " Division by 0 ." , innerException )
176+ ArithmeticException .__ctor__ (this , message or " Attempted to divide by zero ." , innerException )
182177 end
183178})
184179
@@ -192,47 +187,47 @@ define("System.OverflowException", {
192187
193188define (" System.FormatException" , {
194189 __tostring = toString ,
195- __inherits__ = { Exception },
190+ __inherits__ = { SystemException },
196191 __ctor__ = function (this , message , innerException )
197192 ctorOfException (this , message or " Invalid format." , innerException )
198193 end
199194})
200195
201196define (" System.InvalidCastException" , {
202197 __tostring = toString ,
203- __inherits__ = { Exception },
198+ __inherits__ = { SystemException },
204199 __ctor__ = function (this , message , innerException )
205200 ctorOfException (this , message or " Specified cast is not valid." , innerException )
206201 end
207202})
208203
209204define (" System.InvalidOperationException" , {
210205 __tostring = toString ,
211- __inherits__ = { Exception },
206+ __inherits__ = { SystemException },
212207 __ctor__ = function (this , message , innerException )
213208 ctorOfException (this , message or " Operation is not valid due to the current state of the object." , innerException )
214209 end
215210})
216211
217212define (" System.NotImplementedException" , {
218213 __tostring = toString ,
219- __inherits__ = { Exception },
214+ __inherits__ = { SystemException },
220215 __ctor__ = function (this , message , innerException )
221216 ctorOfException (this , message or " The method or operation is not implemented." , innerException )
222217 end
223218})
224219
225220define (" System.NotSupportedException" , {
226221 __tostring = toString ,
227- __inherits__ = { Exception },
222+ __inherits__ = { SystemException },
228223 __ctor__ = function (this , message , innerException )
229224 ctorOfException (this , message or " Specified method is not supported." , innerException )
230225 end
231226})
232227
233228define (" System.NullReferenceException" , {
234229 __tostring = toString ,
235- __inherits__ = { Exception },
230+ __inherits__ = { SystemException },
236231 __ctor__ = function (this , message , innerException )
237232 ctorOfException (this , message or " Object reference not set to an instance of an object." , innerException )
238233 end
0 commit comments