From f2f9b4a6f86f726aac1544fbc4186fa0d494ce06 Mon Sep 17 00:00:00 2001 From: Amir Jafarian Date: Wed, 3 Aug 2016 10:47:40 -0400 Subject: [PATCH] Use g.f instead of utils.format --- lib/dao.js | 24 ++++++++++++------------ lib/list.js | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/dao.js b/lib/dao.js index 38fa3310..37670f2c 100644 --- a/lib/dao.js +++ b/lib/dao.js @@ -1243,7 +1243,7 @@ DataAccessObject._normalize = function(filter) { } var err = null; if ((typeof filter !== 'object') || Array.isArray(filter)) { - err = new Error(g.f(util.format('The query filter %j is not an {{object}}', filter))); + err = new Error(g.f('The query filter %j is not an {{object}}', filter)); err.statusCode = 400; throw err; } @@ -1251,14 +1251,14 @@ DataAccessObject._normalize = function(filter) { var limit = Number(filter.limit || 100); var offset = Number(filter.skip || filter.offset || 0); if (isNaN(limit) || limit <= 0 || Math.ceil(limit) !== limit) { - err = new Error(g.f(util.format('The {{limit}} parameter %j is not valid', - filter.limit))); + err = new Error(g.f('The {{limit}} parameter %j is not valid', + filter.limit)); err.statusCode = 400; throw err; } if (isNaN(offset) || offset < 0 || Math.ceil(offset) !== offset) { - err = new Error(g.f(util.format('The {{offset/skip}} parameter %j is not valid', - filter.skip || filter.offset))); + err = new Error(g.f('The {{offset/skip}} parameter %j is not valid', + filter.skip || filter.offset)); err.statusCode = 400; throw err; } @@ -1289,7 +1289,7 @@ DataAccessObject._normalize = function(filter) { if (dir === 'ASC' || dir === 'DESC') { token = parts[0] + ' ' + dir; } else { - err = new Error(g.f(util.format('The {{order}} %j has invalid direction', token))); + err = new Error(g.f('The {{order}} %j has invalid direction', token)); err.statusCode = 400; throw err; } @@ -1297,7 +1297,7 @@ DataAccessObject._normalize = function(filter) { fields.push(token); } } else { - err = new Error(util.format('The order %j is not valid', order[i])); + err = new Error('The order %j is not valid', order[i]); err.statusCode = 400; throw err; } @@ -1366,7 +1366,7 @@ DataAccessObject._coerce = function(where) { var err; if (typeof where !== 'object' || Array.isArray(where)) { - err = new Error(g.f(util.format('The where clause %j is not an {{object}}', where))); + err = new Error(g.f('The where clause %j is not an {{object}}', where)); err.statusCode = 400; throw err; } @@ -1381,7 +1381,7 @@ DataAccessObject._coerce = function(where) { self._coerce(clauses[k]); } } else { - err = new Error(g.f(util.format('The %s operator has invalid clauses %j', p, clauses))); + err = new Error(g.f('The %s operator has invalid clauses %j', p, clauses)); err.statusCode = 400; throw err; } @@ -1440,14 +1440,14 @@ DataAccessObject._coerce = function(where) { case 'inq': case 'nin': if (!Array.isArray(val)) { - err = new Error(g.f(util.format('The %s property has invalid clause %j', p, where[p]))); + err = new Error(g.f('The %s property has invalid clause %j', p, where[p])); err.statusCode = 400; throw err; } break; case 'between': if (!Array.isArray(val) || val.length !== 2) { - err = new Error(g.f(util.format('The %s property has invalid clause %j', p, where[p]))); + err = new Error(g.f('The %s property has invalid clause %j', p, where[p])); err.statusCode = 400; throw err; } @@ -1455,7 +1455,7 @@ DataAccessObject._coerce = function(where) { case 'like': case 'nlike': if (!(typeof val === 'string' || val instanceof RegExp)) { - err = new Error(g.f(util.format('The %s property has invalid clause %j', p, where[p]))); + err = new Error(g.f('The %s property has invalid clause %j', p, where[p])); err.statusCode = 400; throw err; } diff --git a/lib/list.js b/lib/list.js index 6fc6e63a..bafe8daa 100644 --- a/lib/list.js +++ b/lib/list.js @@ -19,7 +19,7 @@ function List(items, itemType, parent) { try { items = JSON.parse(items); } catch (e) { - var err = new Error(g.f(util.format('could not create List from {{JSON}} string: %j', items))); + var err = new Error(g.f('could not create List from {{JSON}} string: %j', items)); err.statusCode = 400; throw err; } @@ -30,7 +30,7 @@ function List(items, itemType, parent) { items = items || []; if (!Array.isArray(items)) { - var err = new Error(g.f(util.format('Items must be an array: %j', items))); + var err = new Error(g.f('Items must be an array: %j', items)); err.statusCode = 400; throw err; }