summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEugene Obrezkov <ghaiklor@gmail.com>2016-04-21 19:02:27 +0300
committerJames M Snell <jasnell@gmail.com>2016-04-25 08:28:23 -0700
commit1c84579031e34326742c9c264f54625c5918197c (patch)
tree88cec38e667aade677da9d793db57617a310eb31 /lib
parent6c1e5ad3aba4d9ca5883855e1d3838ba8f04dfbb (diff)
downloadnode-new-1c84579031e34326742c9c264f54625c5918197c.tar.gz
console: timeEnd() with no label emits warning
When timeEnd() provided with label that doesn't exists it emits warning in the console, so developer get know about it. PR-URL: https://github.com/nodejs/node/pull/5901 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/console.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/console.js b/lib/console.js
index 646e268624..2359cb36e0 100644
--- a/lib/console.js
+++ b/lib/console.js
@@ -67,9 +67,10 @@ Console.prototype.time = function(label) {
Console.prototype.timeEnd = function(label) {
- var time = this._times.get(label);
+ const time = this._times.get(label);
if (!time) {
- throw new Error(`No such label: ${label}`);
+ process.emitWarning(`No such label '${label}' for console.timeEnd()`);
+ return;
}
const duration = process.hrtime(time);
const ms = duration[0] * 1000 + duration[1] / 1e6;