Open Bug 748505 Opened 12 years ago Updated 2 years ago

Show human-friendly exceptions/nsresult msgs in necko xpcshell tests

Categories

(Core :: Networking: HTTP, defect, P5)

defect

Tracking

()

People

(Reporter: jduell.mcbugs, Unassigned, Mentored)

Details

(Whiteboard: [necko-would-take])

Attachments

(1 file)

I got sick of trying to map nsresult outputs in integer format back to their corresponding NS_ERROR_XXX codes, so I've taught head_channels how to do it for us.

If there's a better way to convert the nsresults into a string than the big switch statement here, I didn't hear it from biesi or bsmedberg on IRC.  In any case, it works.  (biesi: if you are too busy to review whole patch--it's pretty simple--then at least confirm my stringify approach here is ok with you and pass r? along to Patrick).

xpcshell tests also now print the HTTP status and channel status as info messages, which has already helped me debug some stuff.
Attachment #617998 - Flags: review?(cbiesinger)
BTW: silver.uwcs.co.uk/web/mozilla/misc/nserror ;)
Comment on attachment 617998 [details] [diff] [review]
head_channels.js pretty print changes.

+++ b/netwerk/test/unit/head_channels.js
+      request.QueryInterface(Components.interfaces.nsIHttpChannel);
+      test_info("HTTP response status=" + request.responseStatus);

this method is not specific to HTTP channels... so it would be nice not to throw for non-http ones. how about:

  if (request instanceof Components.interfaces.nsIHttpChannel) {
    test_info(...)
  }

+function do_pretty_throw(msg, ex) {

Would be nice to just make do_throw smarter, instead of requiring a separate method!

+    // assume any number of 8 digits or more is an nsresult error code 

ex.result works
Attachment #617998 - Flags: review?(cbiesinger) → review-
Whiteboard: [necko-would-take]
Bulk change to priority: https://bugzilla.mozilla.org/show_bug.cgi?id=1399258
Priority: -- → P5

We already have mozilla::GetErrorName - we probably just need an IDL binding to use in JS.

Assignee: jduell.mcbugs → nobody
Mentor: valentin.gosu
Status: ASSIGNED → NEW
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: