Use g.f instead of utils.format
This commit is contained in:
parent
799d803fa0
commit
f2f9b4a6f8
24
lib/dao.js
24
lib/dao.js
|
@ -1243,7 +1243,7 @@ DataAccessObject._normalize = function(filter) {
|
||||||
}
|
}
|
||||||
var err = null;
|
var err = null;
|
||||||
if ((typeof filter !== 'object') || Array.isArray(filter)) {
|
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;
|
err.statusCode = 400;
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
@ -1251,14 +1251,14 @@ DataAccessObject._normalize = function(filter) {
|
||||||
var limit = Number(filter.limit || 100);
|
var limit = Number(filter.limit || 100);
|
||||||
var offset = Number(filter.skip || filter.offset || 0);
|
var offset = Number(filter.skip || filter.offset || 0);
|
||||||
if (isNaN(limit) || limit <= 0 || Math.ceil(limit) !== limit) {
|
if (isNaN(limit) || limit <= 0 || Math.ceil(limit) !== limit) {
|
||||||
err = new Error(g.f(util.format('The {{limit}} parameter %j is not valid',
|
err = new Error(g.f('The {{limit}} parameter %j is not valid',
|
||||||
filter.limit)));
|
filter.limit));
|
||||||
err.statusCode = 400;
|
err.statusCode = 400;
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
if (isNaN(offset) || offset < 0 || Math.ceil(offset) !== offset) {
|
if (isNaN(offset) || offset < 0 || Math.ceil(offset) !== offset) {
|
||||||
err = new Error(g.f(util.format('The {{offset/skip}} parameter %j is not valid',
|
err = new Error(g.f('The {{offset/skip}} parameter %j is not valid',
|
||||||
filter.skip || filter.offset)));
|
filter.skip || filter.offset));
|
||||||
err.statusCode = 400;
|
err.statusCode = 400;
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
@ -1289,7 +1289,7 @@ DataAccessObject._normalize = function(filter) {
|
||||||
if (dir === 'ASC' || dir === 'DESC') {
|
if (dir === 'ASC' || dir === 'DESC') {
|
||||||
token = parts[0] + ' ' + dir;
|
token = parts[0] + ' ' + dir;
|
||||||
} else {
|
} 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;
|
err.statusCode = 400;
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
@ -1297,7 +1297,7 @@ DataAccessObject._normalize = function(filter) {
|
||||||
fields.push(token);
|
fields.push(token);
|
||||||
}
|
}
|
||||||
} else {
|
} 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;
|
err.statusCode = 400;
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
@ -1366,7 +1366,7 @@ DataAccessObject._coerce = function(where) {
|
||||||
|
|
||||||
var err;
|
var err;
|
||||||
if (typeof where !== 'object' || Array.isArray(where)) {
|
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;
|
err.statusCode = 400;
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
@ -1381,7 +1381,7 @@ DataAccessObject._coerce = function(where) {
|
||||||
self._coerce(clauses[k]);
|
self._coerce(clauses[k]);
|
||||||
}
|
}
|
||||||
} else {
|
} 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;
|
err.statusCode = 400;
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
@ -1440,14 +1440,14 @@ DataAccessObject._coerce = function(where) {
|
||||||
case 'inq':
|
case 'inq':
|
||||||
case 'nin':
|
case 'nin':
|
||||||
if (!Array.isArray(val)) {
|
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;
|
err.statusCode = 400;
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'between':
|
case 'between':
|
||||||
if (!Array.isArray(val) || val.length !== 2) {
|
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;
|
err.statusCode = 400;
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
@ -1455,7 +1455,7 @@ DataAccessObject._coerce = function(where) {
|
||||||
case 'like':
|
case 'like':
|
||||||
case 'nlike':
|
case 'nlike':
|
||||||
if (!(typeof val === 'string' || val instanceof RegExp)) {
|
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;
|
err.statusCode = 400;
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ function List(items, itemType, parent) {
|
||||||
try {
|
try {
|
||||||
items = JSON.parse(items);
|
items = JSON.parse(items);
|
||||||
} catch (e) {
|
} 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;
|
err.statusCode = 400;
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ function List(items, itemType, parent) {
|
||||||
|
|
||||||
items = items || [];
|
items = items || [];
|
||||||
if (!Array.isArray(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;
|
err.statusCode = 400;
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue