Open Bug 1802347 Opened 1 year ago Updated 1 year ago

Replace the two-argument form (message + stack) of Cu.reportError with console.error

Categories

(Toolkit :: General, task, P3)

task

Tracking

()

People

(Reporter: standard8, Unassigned)

References

(Blocks 1 open bug)

Details

For the current cases where we pass a stack argument, we should be able to replace them with equivalents using console.error, e.g.

let error = new Error()
error.stack = stack;
console.error(error);

This is being split out from the initial no-cu-reportError landing, as it is a little more work as the instances probably need to be replaced manually / with extra checks.

The stack is a magic property that can't just be overwritten and everything works. Internally the stack is actually a getter that creates a string based on the stack frame objects inside the error object.

In my testing when overwriting the stack property the webconsole just stops displaying a stack altogether.

(In reply to Tom Schuster [:evilpie] from comment #1)

The stack is a magic property that can't just be overwritten and everything works. Internally the stack is actually a getter that creates a string based on the stack frame objects inside the error object.

In my testing when overwriting the stack property the webconsole just stops displaying a stack altogether.

I'm a little surprised by this as the devtools team suggested it, and assigning stacks seemed to work when I tried it out. Have you tried in privileged code?

The instances are limited to the extension code, and there looks to be a test covering at least one of the message reporting, so hopefully we can use that to validate when we get to this.

If it really doesn't work, then worst case we can either ask the devtools team to provide a facility or rename Cu.reportError to something that makes it explicit that it is only for reporting stacks.

It also doesn't work in the browser console, which is really what I expected.

You need to log in before you can comment on or make changes to this bug.