Subj : Re: Error handling To : netscape.public.mozilla.jseng From : Braden McDaniel Date : Mon Aug 04 2003 06:30 pm On Sun, 11 May 2003 10:22:35 -0700, Brendan Eich wrote: > >>>Errors other than "out of memory" become exceptions. >>> >>> >> >>"Become"? Does that mean an exception is thrown as a result of calling >>JS_ReportError? What exception? >> > > Lxr for JS_HAS_ERROR_EXCEPTIONS. Reporting an error throws an > exception. The type and details depend on the parameters you put in > your .msg file. You'll want to look at js.msg and jsshell.msg and > imitate those. Also see where they're #included with an appropriate > MSG_DEF macro definition inside an array initializer, to initialize the > js_ErrorFormatString table in jscntxt.c, e.g. > > >>> If you need >>>localizable error messages, you'll have to supply your own >>>JSErrorCallback (see js.c for an example). >>> >>> >> >>You mean JSErrorReporter? >> > > No, I mean a (const JSErrorFormatString *)-returning callback function > such as js_GetErrorMessage in jscntxt.c, or my_GetErrorMessage in js.c. > > >>> If you want to signal >>>conditions other than errors, you can throw objects or primitive values, >>>however you please. >>> >>> >> >>The particular conditions I'm dealing with now are: >> >> * Insufficent number of arguments to a function. >> * Inappropriate type passed to function. >> >>For the latter, I think I want to throw a TypeError. >>(JS_SetPendingException, right?) I'm not sure about the former; does it >>qualify as a condition other than an error? >> > > No, it sounds like an error. > > Use JSEXN_TYPEERR in your js.msg clone for type errors. Sorry... I got distracted by other things. I'm now getting back to this. I've gone through the SpiderMonkey code to see how it uses exceptions. I don't see how errors defined in *my* js.msg file get mapped to exceptions. The logic that maps error definitions to exception types in jsexn.c (js_ErrorToException) seems tied to the SpiderMonkey js.msg. What am I missing? -- Braden McDaniel e-mail: Jabber: .