beautify-benchmark icon indicating copy to clipboard operation
beautify-benchmark copied to clipboard

Errors not being displayed.

Open melinath opened this issue 8 years ago • 3 comments

I'm using this as described in the README but errors are not being displayed. My code:

suite.on('cycle', function(event) {
	if (event.target.error) {
		console.log(event.target.error)
	}
	beautifyBenchmark.add(event.target)
})

suite.on('complete', function() {
	beautifyBenchmark.log()
})

The console.log is printing out the errors, but beautify-benchmark never does.

melinath avatar Apr 12 '17 23:04 melinath

Okay, so it looks like the problem is that if a runtime error happens it's an instance of Error, which has non-enumerable properties. i.e. Using Object.keys() returns an empty array whereas Object.getOwnPropertyNames() returns an actually useful list.

melinath avatar Apr 12 '17 23:04 melinath

Arguably though this should just be rendering the stack trace (which includes the error message) rather than displaying a comma-separated list of all the attributes.

melinath avatar Apr 12 '17 23:04 melinath

Workaround for now:

suite.on('cycle', function(event) {
	if (event.target.error) {
		event.target.error = {
			stack: event.target.error.stack,
		}
	}
	beautifyBenchmark.add(event.target)
})

melinath avatar Apr 12 '17 23:04 melinath