Skip to content

Commit

Permalink
Report errors from instantiating Intl objects
Browse files Browse the repository at this point in the history
  • Loading branch information
stasm committed Jul 19, 2019
1 parent 48a11f8 commit c9b38d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions fluent/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ export class FluentNumber extends FluentType {
Intl.NumberFormat, this.opts
);
return nf.format(this.value);
} catch (e) {
// XXX Report the error.
} catch (err) {
scope.reportError(err);
return this.value;
}
}
Expand All @@ -83,8 +83,8 @@ export class FluentDateTime extends FluentType {
Intl.DateTimeFormat, this.opts
);
return dtf.format(this.value);
} catch (e) {
// XXX Report the error.
} catch (err) {
scope.reportError(err);
return this.value;
}
}
Expand Down
6 changes: 4 additions & 2 deletions fluent/test/functions_builtin_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ suite('Built-in functions', function() {

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

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

test('number argument', function() {
Expand Down

0 comments on commit c9b38d3

Please sign in to comment.