Subj : Re: Error handling To : netscape.public.mozilla.jseng From : Braden McDaniel Date : Sun May 11 2003 12:17 am On Sat, 10 May 2003 01:21:41 -0700, Brendan Eich wrote: > Braden McDaniel wrote: > >>I'm trying to get a feel for the Right way to handle errors in >>implementing my own JavaScript classes and functions using SpiderMonkey. >>Is throwing an exception generally preferred to calling JS_ReportError? If >>not, when is each appropriate? >> > > 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? > If you need > localizable error messages, you'll have to supply your own > JSErrorCallback (see js.c for an example). You mean JSErrorReporter? > 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? -- Braden McDaniel e-mail: Jabber: .