Skip to content

Commit c9b38d3

Browse files
committed
Report errors from instantiating Intl objects
1 parent 48a11f8 commit c9b38d3

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

fluent/src/types.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ export class FluentNumber extends FluentType {
6565
Intl.NumberFormat, this.opts
6666
);
6767
return nf.format(this.value);
68-
} catch (e) {
69-
// XXX Report the error.
68+
} catch (err) {
69+
scope.reportError(err);
7070
return this.value;
7171
}
7272
}
@@ -83,8 +83,8 @@ export class FluentDateTime extends FluentType {
8383
Intl.DateTimeFormat, this.opts
8484
);
8585
return dtf.format(this.value);
86-
} catch (e) {
87-
// XXX Report the error.
86+
} catch (err) {
87+
scope.reportError(err);
8888
return this.value;
8989
}
9090
}

fluent/test/functions_builtin_test.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ suite('Built-in functions', function() {
6767

6868
msg = bundle.getMessage('num-bad-opt');
6969
assert.strictEqual(bundle.formatPattern(msg.value, args, errors), '1');
70-
assert.strictEqual(errors.length, 0);
70+
assert.strictEqual(errors.length, 1);
71+
assert.ok(errors[0] instanceof RangeError); // Invalid option value
7172
});
7273

7374
test('string argument', function() {
@@ -222,7 +223,8 @@ suite('Built-in functions', function() {
222223
// may vary depending on the TZ:
223224
// Thu Sep 29 2016 02:00:00 GMT+0200 (CEST)
224225
assert.strictEqual(bundle.formatPattern(msg.value, args, errors), date.toString());
225-
assert.strictEqual(errors.length, 0);
226+
assert.strictEqual(errors.length, 1);
227+
assert.ok(errors[0] instanceof RangeError); // Invalid option value
226228
});
227229

228230
test('number argument', function() {

0 commit comments

Comments
 (0)