Skip to content

Commit bd0643e

Browse files
authored
Merge pull request #463 from geghamyan/improve-error-logging
Added type check for console.error args to prevent startsWith() error…
2 parents 7803213 + 35e70ec commit bd0643e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

chatgpt.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,8 +2132,11 @@ function toCamelCase(words) {
21322132
// Prefix console logs w/ '🤖 chatgpt.js >> '
21332133
const consolePrefix = '🤖 chatgpt.js >> ', ogError = console.error, ogInfo = console.info
21342134
console.error = (...args) => {
2135-
if (!args[0].startsWith(consolePrefix)) ogError(consolePrefix + args[0], ...args.slice(1))
2136-
else ogError(...args)
2135+
if (typeof args[0] === 'string') {
2136+
if (!args[0].startsWith(consolePrefix)) ogError(consolePrefix + args[0], ...args.slice(1))
2137+
else ogError(...args)
2138+
}
2139+
else ogError(consolePrefix, ...args)
21372140
}
21382141
console.info = (msg) => {
21392142
if (!msg.startsWith(consolePrefix)) ogInfo(consolePrefix + msg);

0 commit comments

Comments
 (0)