Skip to content

Commit

Permalink
fix(client): Only create the funky object if message is not a string
Browse files Browse the repository at this point in the history
Fixes #3296
  • Loading branch information
johnjbarton committed Apr 12, 2019
1 parent 7eb48c5 commit 2968f47
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions client/karma.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,23 @@ function Karma (socket, iframe, opener, navigator, location) {
// error during js file loading (most likely syntax error)
// we are not going to execute at all. `window.onerror` callback.
this.error = function (messageOrEvent, source, lineno, colno, error) {
var message = messageOrEvent
var location = getLocation(source, lineno, colno)
var message
if (typeof messageOrEvent === 'string') {
message = messageOrEvent

if (location !== '') {
message += '\nat ' + location
}

if (error) {
message += '\n\n' + error.stack
var location = getLocation(source, lineno, colno)
if (location !== '') {
message += '\nat ' + location
}
if (error && error.stack) {
message += '\n\n' + error.stack
}
} else {
// create an object with the string representation of the message to
// ensure all its content is properly transferred to the console log
message = {message: messageOrEvent, str: messageOrEvent.toString()}
}

// create an object with the string representation of the message to ensure all its content is properly
// transferred to the console log
message = {message: message, str: message.toString()}

socket.emit('karma_error', message)
this.complete()
return false
Expand Down

0 comments on commit 2968f47

Please sign in to comment.