mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-05-07 22:56:36 +00:00
17 lines
561 B
JavaScript
17 lines
561 B
JavaScript
|
|
// errorMessage(key) will be called by all common-ops , which is also imported to the website
|
||
|
|
|
||
|
|
import _clone from 'lodash/clone';
|
||
|
|
import _template from 'lodash/template';
|
||
|
|
|
||
|
|
import messages from '../../errors/commonErrorMessages';
|
||
|
|
|
||
|
|
export default function (msgKey, vars = {}) {
|
||
|
|
let message = messages[msgKey];
|
||
|
|
if (!message) throw new Error(`Error processing the common message "${msgKey}".`);
|
||
|
|
|
||
|
|
let clonedVars = vars ? _clone(vars) : {};
|
||
|
|
|
||
|
|
// TODO cache the result of template() ? More memory usage, faster output
|
||
|
|
return _template(message)(clonedVars);
|
||
|
|
}
|