Skip to content

Commit

Permalink
Merge pull request #270 from jairo-bc/STRF-9658-fix
Browse files Browse the repository at this point in the history
STRF-9658 logger accepts strings instead of objects
  • Loading branch information
jairo-bc authored Mar 2, 2022
2 parents 48ff533 + 40c1508 commit fa94724
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/translator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Translator.prototype.translate = function (key, parameters) {
try {
return this._formatFunctions[key](parameters);
} catch (err) {
this._logger.error(err);
this._logger.error(err.message);
return '';
}
};
Expand Down
3 changes: 3 additions & 0 deletions spec/lib/translator.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ describe('Translator', () => {

expect(translator.translate('hello')).to.equal('');
expect(loggerStub.error.called).to.equal(true);
expect(loggerStub.error.getCall(0).args[0]).to.equal("MessageFormat: Data required for 'name'.")

done();
});
Expand All @@ -143,8 +144,10 @@ describe('Translator', () => {
}, loggerStub);

const result = translator.translate('items_with_syntax_error', { count: 1 });
const errMessage = 'Language File Syntax Error: Expected "plural" or "select" but "p" found. for key "items_with_syntax_error"';
expect(result).to.equal("");
expect(loggerStub.error.called).to.equal(true);
expect(loggerStub.error.getCall(0).args[0]).to.equal(errMessage);

done();
});
Expand Down

0 comments on commit fa94724

Please sign in to comment.