0

I'm in the process of modifying the Jint 2.0.0 javascript engine to my bidding, but I'm discovering that there's a severe lack of error messages to return to the user. My application must be usable by beginners to JS so I really want to be able to give good feedback on any mistakes.

The documentation for Jint is, well, minimal and I've checked out the ECMAScript specification and they don't provide anything helpful either. See this PutValue example. It simply specifies that at a giving point:

"Throw ReferenceError exception."

Which is totally unhelpful.

I had the idea of trying to replicate each possible error in a finished polished ECMAScript implementation like V8 and see what they have, but damn, that sounds like a lot of work. And I risk not getting the whole array of possible return messages for each error.

I'm about to download the V8 source and see if they have a list of error messages stored somewhere obvious. Does any one know if that exists and if so where it is?

Apart from that I'm drawing a blank. Any one got any ideas? I would be extremely grateful for anything at all. Thank you!

dakotapearl
  • 373
  • 1
  • 15
  • 1
    Complain to the authors of the project/implementation. Not much we can do here... – leppie Dec 15 '14 at 18:14
  • They don't seem too active any more unfortunately... I'll give it a go though. Thanks leppie – dakotapearl Dec 15 '14 at 18:17
  • Yes, the ECMAScript reference only specifies *that* a `ReferenceError` should be thrown, so that each implementation can put the *most usable* error description text on it, which depends a lot on the implementation. – Bergi Dec 15 '14 at 18:48
  • I'm pretty sure V8 has a bunch of files with error messages, as they are well localised. I don't have a link at hand, but you'll find it. – Bergi Dec 15 '14 at 18:49
  • Ha, Bergi, just as you posted that I found the file! V8Source/src/message.js – dakotapearl Dec 15 '14 at 18:50
  • I just need to do a bit of guess work to place them now. Thanks guys! – dakotapearl Dec 15 '14 at 18:50

1 Answers1

0

For anyone looking for this in the future, get the V8 source:

https://code.google.com/p/v8-wiki/wiki/UsingGit

and look in src/messages.js. They're right at the top of the file. You'll have to do a search for the name of the error to find it's place in the source code though. On linux or in cygwin, you can use for example

grep -R 'unexpected_token' . 
dakotapearl
  • 373
  • 1
  • 15