fholm / IronJS

IronJS - A JavaScript implementation for .NET
http://ironjs.wordpress.com
Apache License 2.0
680 stars 79 forks source link

"TypeError: N" is unhelpful. #50

Open otac0n opened 13 years ago

otac0n commented 13 years ago

Take this for example:

"abc".substr(0, 2);

This should throw an error indicating that the String prototype does not contain a method called "substr", but rather throws an error with the message "TypeError: N", which is entirely unhelpful.

axefrog commented 13 years ago

Would love to see exceptions thrown by the runtime updated so they have helpful messages. This would make it a lot easier to figure out why they have been thrown without needing a deep understanding of IronJS' internals.

Using the wiki article Create a custom javascript object, I created my first custom object for use my with my JavaScript context. Construction of the object worked fine, but when I called the method LoadURL on my object, the following exception was thrown:

Exception thrown: IronJS.UserError: TypeError: 8 at IronJS.Hosting.FSharp.run(Delegate compiled, T t) in C:\Users\otac0n\Projects\IronJS\Src\IronJS\Hosting.fs:line 151 at IronJS.Hosting.CSharp.Context.Execute(String source) in C:\Users\otac0n\Projects\IronJS\Src\IronJS\Hosting.fs:line 240 at ...

Debugging eventually revealed that it was my fault - I messed up the casing when calling my custom object's only function, but this took me a while to realise due to the obscure error message.

crpietschmann commented 13 years ago

Agreed! "TypeError: N" is really useless for debugging.