Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(client): Only create the funky object if message is not a string #3298

Merged
merged 1 commit into from
Apr 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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