@@ -145,21 +145,23 @@ function Karma (socket, iframe, opener, navigator, location) { |
145 | 145 | // error during js file loading (most likely syntax error) |
146 | 146 | // we are not going to execute at all. `window.onerror` callback. |
147 | 147 | this.error = function (messageOrEvent, source, lineno, colno, error) { |
148 | | - var message = messageOrEvent |
149 | | - var location = getLocation(source, lineno, colno) |
| 148 | + var message |
| 149 | + if (typeof messageOrEvent === 'string') { |
| 150 | + message = messageOrEvent |
150 | 151 |
|
151 | | - if (location !== '') { |
152 | | - message += '\nat ' + location |
153 | | - } |
154 | | - |
155 | | - if (error) { |
156 | | - message += '\n\n' + error.stack |
| 152 | + var location = getLocation(source, lineno, colno) |
| 153 | + if (location !== '') { |
| 154 | + message += '\nat ' + location |
| 155 | + } |
| 156 | + if (error && error.stack) { |
| 157 | + message += '\n\n' + error.stack |
| 158 | + } |
| 159 | + } else { |
| 160 | + // create an object with the string representation of the message to |
| 161 | + // ensure all its content is properly transferred to the console log |
| 162 | + message = {message: messageOrEvent, str: messageOrEvent.toString()} |
157 | 163 | } |
158 | 164 |
|
159 | | - // create an object with the string representation of the message to ensure all its content is properly |
160 | | - // transferred to the console log |
161 | | - message = {message: message, str: message.toString()} |
162 | | - |
163 | 165 | socket.emit('karma_error', message) |
164 | 166 | this.complete() |
165 | 167 | return false |
|