Closed Bug 869372 Opened 11 years ago Closed 11 years ago

Don't silence unknown errors in promises

Categories

(L20n :: JS Library, defect, P3)

x86_64
Linux
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: stas, Assigned: stas)

Details

Attachments

(1 file, 2 obsolete files)

When we're in async mode (the first locale isn't built yet), the translations listening to 'ready' and those registered via ctx.localize may return an unknown error but it will be silent, making debugging hard.

This is because freeze() uses a Promise with no errback.
Attached patch Pass an errback to then() (obsolete) — Splinter Review
Assignee: nobody → stas
Attachment #746325 - Flags: review?(gandalf)
Priority: -- → P3
Target Milestone: --- → 1.0
Comment on attachment 746325 [details] [diff] [review]
Pass an errback to then()

I'm not sure if context.js should refer console.* object. I don't know how widespread console.* is but I don't believe it to be part of DOM standard.

Should we define it in bindings?
You're right, it's not.  It's defined in most browsers (IE9+) and in node.js, but for instance XPCShell doesn't define it;  it has `dump` instead.

Can we define it in the postfix files which are appended to the dist file?  

An alternative would be to emit the error, not console.log it.
I'd prefer emitting it I believe.
Attached patch Emit 'debug' events (obsolete) — Splinter Review
I like emitting too.  We can listen to these events and console.(log|warn|error) them in the bindings.  In this patch I propose that we emit known and safe context errors as 'error' events, and unknown JS-related, possibly fatal errors as 'debug'.  We can discuss this and clean it up in bug 802850.

If someone wants to do something else with the event, we should let them do so.  Right now it's hard bacause document.l10n isn't immediately available, see bug 882601.
Attachment #746325 - Attachment is obsolete: true
Attachment #746325 - Flags: review?(gandalf)
Attachment #761927 - Flags: review?(gandalf)
Oops, I forgot about gaia.js.
Attachment #761927 - Attachment is obsolete: true
Attachment #761927 - Flags: review?(gandalf)
Attachment #761930 - Flags: review?(gandalf)
Attachment #761930 - Flags: review?(gandalf) → review+
https://github.com/l20n/l20n.js/commit/2f54c63d299dc6cdb801b20fc733ca3584fd4ecf
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: