Closed Bug 298336 Opened 20 years ago Closed 6 years ago

xpconnect js out argument conversion error is NS_ERROR_FAILURE

Categories

(Core :: XPConnect, defect)

PowerPC
macOS
defect
Not set
normal

Tracking

()

RESOLVED INACTIVE

People

(Reporter: timeless, Assigned: timeless)

References

()

Details

Attachments

(1 file)

in this simple example, you can easily see what's wrong and why, unfortunately
with real code, it was a different story.

js>
SIP=Components.Constructor("@mozilla.org/supports-interface-pointer;1",Components.interfaces.nsISupportsInterfacePointer)
[object nsXPCConstructor]
js> sip=new SIP;
[interface pointer]
js> a={iids:[Components.interfaces.nsISupports,Components.interfaces.nsIFile],
QueryInterface:function (iid) { for (var i in this.iids) if
(this.iids[i].equals(iid)) return this; throw
Components.results.NS_ERROR_NO_INTERFACE}, get parent(){return
10}};sip.data=a;sip.data instanceof a.iids[1];sip.data
[xpconnect wrapped nsIFile]
js> sip.data.parent
uncaught exception: [Exception... "Component returned failure code: 0x80004005
(NS_ERROR_FAILURE) [nsIFile.parent]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"
 location: "JS frame :: typein :: <TOP_LEVEL> :: line 5"  data: no]
js> sip.data.parent
typein:32: Component returned failure code: 0x8057003b
(NS_ERROR_XPC_BAD_CONVERT_RETURN) [nsIFile.parent]
Attachment #187111 - Flags: review?(dbradley)
Comment on attachment 187111 [details] [diff] [review]
be more descriptive about the problem

I think we should try and presever the error value from
XPCConvert::JSData2Native interface. It might provide more specific
information, though, from the looks of it, it doesn't. But that's another
issue.

Ideally it would be nice to report the parameter's index. I've cursed Microsoft
many times for similar lack in IDispatch. That's kind of where you were heading
with the retval vs out param variation of error codes anyway.

So I think this should just use NS_ERROR_XPC_BAD_CONVERT_JS for the
non-JSData2Native cases and then pass in the error return variable for the
JSData2Native case and return that. Knowing that its a return vs out parameter
would be nice, but I'd like to see a solution that gives people real
information about the location of problem
Attachment #187111 - Flags: review?(dbradley) → review-
QA Contact: pschwartau → xpconnect
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

Creator:
Created:
Updated:
Size: