Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(client): Only create the funky object if message is not a string (#…
…3298)

Fixes #3296
  • Loading branch information
johnjbarton committed Apr 15, 2019
1 parent 7968db6 commit ce6825f
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions client/karma.js
Expand Up @@ -145,21 +145,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 ce6825f

Please sign in to comment.