Open
Bug 1474287
Opened 6 years ago
Updated 2 years ago
Full error messages not logged in the console (mach + xpcshell)
Categories
(Testing :: XPCShell Harness, defect, P3)
Tracking
(Not tracked)
NEW
People
(Reporter: ladybenko, Unassigned)
Details
(Whiteboard: dev-prod-2020)
Attachments
(1 file)
56.20 KB,
patch
|
Details | Diff | Splinter Review |
When running xpcshell tests with mach, and there's a JS error in the code, instead of getting the actual error type and message, I'm getting a generic "ERROR NS_ERROR_NOT_AVAILABLE" plus the line and file, which makes debugging more difficult.
Comment 1•6 years ago
|
||
Can you provide a log showing the problem? Copy/paste the command line + the relevant output as a comment, or redirect output to a file and attach here, please.
Flags: needinfo?(balbeza)
Comment 2•6 years ago
|
||
There's a chance you can get what you need with existing command line arguments, like 'mach xpcshell-test --verbose ...' or possibly --log-mach-level=debug. See 'mach help xpcshell-test' or 'mach help test' for help on many options.
Reporter | ||
Comment 3•6 years ago
|
||
Flags: needinfo?(balbeza)
Reporter | ||
Comment 4•6 years ago
|
||
Hi, thanks! I've tried with both verbose and debug and I can't still get the error message. I'm attaching a patch to reproduce. Apply the patch, build Firefox and then run `./mach test devtools/client/application/test/unit/test_component.js`
Comment 5•6 years ago
|
||
I guess command line options won't help here after all. I see: ... 0:01.39 ERROR NS_ERROR_NOT_AVAILABLE: @/home/gbrown/objdirs/firefox/_tests/xpcshell/devtools/client/application/test/unit/test_component.js:5:17 load_file@/home/gbrown/src/testing/xpcshell/head.js:640:7 _load_files@/home/gbrown/src/testing/xpcshell/head.js:652:3 _execute_test@/home/gbrown/src/testing/xpcshell/head.js:506:3 @-e:1:1 ... That error message is formatted by https://dxr.mozilla.org/mozilla-central/rev/085cdfb90903d4985f0de1dc7786522d9fb45596/testing/xpcshell/head.js#764 If I simply log the caught error instead, I get: 0:00.45 ERROR [Exception... "Component is not available" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: /home/gbrown/objdirs/firefox/_tests/xpcshell/devtools/client/application/test/unit/test_component.js :: <TOP_LEVEL> :: line 5" data: no] Is it the "0x80040111" and/or "Component is not available" text that you want to see?
Reporter | ||
Comment 6•6 years ago
|
||
Hi Geoff, thanks for looking into this. "Component is not available" is definitely something I'd like to see. In this case in particular, I actually thought that "NS_ERROR_NOT_AVAILABLE" meant that the error itself couldn't be retrieved (i.e. a tool error rather than a JavaScript error). Human-readable errors instead of (or in addition to) error codes would help a lot.
Comment 7•6 years ago
|
||
Looking at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error, it seems "name" and "message" are the only relevant standard properties. The xpcshell error logging already reports both. In this case, name = "NS_ERROR_NOT_AVAILABLE" and message = "". I think "Component is not available" can only be accessed with toString(), which returns all that other text like "nsresult: ... location: ... data: ...". I wouldn't want to dump the error's toString() text in addition to the existing stack: ERROR NS_ERROR_NOT_AVAILABLE: @/home/gbrown/objdirs/firefox/_tests/xpcshell/devtools/client/application/test/unit/test_component.js:5:17 load_file@/home/gbrown/src/testing/xpcshell/head.js:640:7 _load_files@/home/gbrown/src/testing/xpcshell/head.js:652:3 _execute_test@/home/gbrown/src/testing/xpcshell/head.js:506:3 @-e:1:1 ERROR [Exception... "Component is not available" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: /home/gbrown/objdirs/firefox/_tests/xpcshell/devtools/client/application/test/unit/test_component.js :: <TOP_LEVEL> :: line 5" data: no] I think the redundancy -- 2x "NS_ERROR_NOT_AVAILABLE", stack + location -- would be confusing. And I wouldn't want to remove the existing stack reporting, which is obviously more exact and more useful than the simple location returned by toString(). I would like to see text like "Component is not available" included when it is available, but I don't see a generic way to do that without losing some of the benefits of the existing error reporting.
Priority: -- → P3
Comment 8•6 years ago
|
||
It sounds more like an issue with ChromeUtils.import, called from test_component.js:5, that doesn't throw an error with meaningful error message, rather than an issue with xpcshell test harness. Component is not available is the string to describe NS_ERROR_NOT_AVAILABLE: https://searchfox.org/mozilla-central/search?q=Component+is+not+available&case=false®exp=false&path= I'm not sure there is any API to fetch it from the exception, nor any api to translate a code into a message. Also, I'm not sure if it is really helpful to retrieve the message, but you could do that via: const message = exception.__proto__ == Components.Exception().__proto__ ? exception.toString().match(/\"([^"]*)\"/)[1] : null;
Updated•4 years ago
|
Whiteboard: dev-prod-2020
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•