Fix logger
This commit is contained in:
parent
6cbda76fea
commit
68c04f6224
2 changed files with 7 additions and 7 deletions
|
@ -39,7 +39,7 @@ var random = {
|
||||||
range: function (start, limit) {
|
range: function (start, limit) {
|
||||||
// Returns an integer in [start, limit]. Uniform distribution.
|
// Returns an integer in [start, limit]. Uniform distribution.
|
||||||
if (isNaN(start) || isNaN(limit)) {
|
if (isNaN(start) || isNaN(limit)) {
|
||||||
logger.console.traceback()
|
logger.traceback()
|
||||||
throw new TypeError('random.range() received a non number type: \'' + start + '\', \'' + limit + '\')')
|
throw new TypeError('random.range() received a non number type: \'' + start + '\', \'' + limit + '\')')
|
||||||
}
|
}
|
||||||
return this.number(limit - start + 1) + start
|
return this.number(limit - start + 1) + start
|
||||||
|
@ -50,7 +50,7 @@ var random = {
|
||||||
},
|
},
|
||||||
item: function (list) {
|
item: function (list) {
|
||||||
if (!(list instanceof Array || (list !== undefined && typeof list !== 'string' && list.hasOwnProperty('length')))) {
|
if (!(list instanceof Array || (list !== undefined && typeof list !== 'string' && list.hasOwnProperty('length')))) {
|
||||||
logger.console.traceback()
|
logger.traceback()
|
||||||
throw new TypeError('this.item() received a non array type: \'' + list + '\'')
|
throw new TypeError('this.item() received a non array type: \'' + list + '\'')
|
||||||
}
|
}
|
||||||
return list[this.number(list.length)]
|
return list[this.number(list.length)]
|
||||||
|
@ -86,7 +86,7 @@ var random = {
|
||||||
},
|
},
|
||||||
choose: function (list, flat) {
|
choose: function (list, flat) {
|
||||||
if (!(list instanceof Array)) {
|
if (!(list instanceof Array)) {
|
||||||
logger.console.traceback()
|
logger.traceback()
|
||||||
throw new TypeError('random.choose() received a non-array type: \'' + list + '\'')
|
throw new TypeError('random.choose() received a non-array type: \'' + list + '\'')
|
||||||
}
|
}
|
||||||
let total = 0
|
let total = 0
|
||||||
|
@ -138,7 +138,7 @@ var random = {
|
||||||
},
|
},
|
||||||
subset: function (list, limit) {
|
subset: function (list, limit) {
|
||||||
if (!(list instanceof Array)) {
|
if (!(list instanceof Array)) {
|
||||||
logger.console.traceback()
|
logger.traceback()
|
||||||
throw new TypeError('random.some() received a non-array type: \'' + list + '\'')
|
throw new TypeError('random.some() received a non-array type: \'' + list + '\'')
|
||||||
}
|
}
|
||||||
if (typeof limit !== 'number') {
|
if (typeof limit !== 'number') {
|
||||||
|
|
|
@ -26,7 +26,7 @@ Objects.prototype.add = function (category, member) {
|
||||||
Objects.prototype.get = function (category, last) {
|
Objects.prototype.get = function (category, last) {
|
||||||
if (!(category in this.container)) {
|
if (!(category in this.container)) {
|
||||||
// return {type:null, name:null};
|
// return {type:null, name:null};
|
||||||
logger.console.traceback()
|
logger.traceback()
|
||||||
throw new Error(category + ' is not available.')
|
throw new Error(category + ' is not available.')
|
||||||
}
|
}
|
||||||
if (last) {
|
if (last) {
|
||||||
|
@ -39,8 +39,8 @@ Objects.prototype.pick = function (category, last) {
|
||||||
try {
|
try {
|
||||||
return this.get(category, last).name
|
return this.get(category, last).name
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.console.traceback()
|
logger.traceback()
|
||||||
throw logger.console.JSError('Error: pick(' + category + ') ' + category + ' is undefined.')
|
throw logger.JSError('Error: pick(' + category + ') ' + category + ' is undefined.')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue