Closed Bug 291374 Opened 20 years ago Closed 6 years ago

RFE: better error reporting for "object has no method named" in XPConnect calls to JS-impl'd ifaces

Categories

(Core :: XPConnect, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED INACTIVE

People

(Reporter: shaver, Unassigned)

Details

Attachments

(1 file)

Right now, you don't find out anything but the fact that we tried to call
nsIObserver::observe on _something_, and it didn't have the attribute.

I have a patch to leverage the __LOCATION__ property I added to
component-globals and improve the error reporting to at least include the
filename.  It is not a pretty patch, and I would want to refactor it a bit to
avoid the somewhat-nasty overload of aData-as-stack it introduces in
XPCConvert::ConstructException, but it really makes debugging out-of-whack
components a fair sight better.

I think I'd also like to take a swing at including the object's
.constructor.name property, if present, to give a still-better hint to the
developer. 

Comments very much desired.  (To test this patch, I recommend writing a simple
component that registers against "xpcom-startup" as an observer, and doesn't
implement an |observe| function.  Makes testing in xpcshell a breeze.)
I'm not even going to request review on this, but don't let that keep you from
providing comments!
Severity --> enhancement due to partical summary "REF: "
Severity: normal → enhancement
Comment on attachment 181469 [details] [diff] [review]
mildly, but usefully, better reporting

>Index: xpcwrappedjsclass.cpp
>@@ -1358,9 +1359,51 @@ pre_call_clean_up:
i believe this needs a null check: (and rooting?) (and should you consider
atomizing?)
>+            JSString *str = JS_NewStringCopyZ(cx, "__LOCATION__");
>+            if (JS_ValueToId(cx, STRING_TO_JSVAL(str), &locId) &&
>+                OBJ_GET_PROPERTY(cx, outermostScope, locId, &locval) && 
>+                !XPCConvert::JSData2Native(ccx, &location,
>+                                           locval, type, JS_FALSE,
>+                                           &NS_GET_IID(nsILocalFile), &retval)) {
Yes, yes, there are all sorts of robustness issues there; I'm looking for
comments on the general approach, not on my punctuation.
seems ok to me. *shrug* :)
QA Contact: pschwartau → xpconnect
Mass abdication.
Assignee: shaver → nobody
Per policy at https://wiki.mozilla.org/Bug_Triage/Projects/Bug_Handling/Bug_Husbandry#Inactive_Bugs. If this bug is not an enhancement request or a bug not present in a supported release of Firefox, then it may be reopened.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → INACTIVE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: