Skip to content

Commit 59a3130

Browse files
committed
🔊 improved client method error logs #2316
1 parent cd95aed commit 59a3130

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

src/api/Client.ts

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -542,17 +542,30 @@ export class Client {
542542
const res = await this._page.evaluate(pageFunction, ...args);
543543
if(this._createConfig.onError && typeof res == "string" && (res.startsWith("Error") || res.startsWith("ERROR"))) {
544544
const e = this._createConfig.onError;
545-
if(e == OnError.AS_STRING || e == OnError.NOTHING) return res
546-
if(e == OnError.LOG_AND_FALSE) {
547-
console.error(res);
548-
return true;
549-
}
550-
if(e == OnError.LOG_AND_STRING) {
551-
console.error(res);
552-
return res;
553-
}
545+
/**
546+
* Log error
547+
*/
548+
if(
549+
e == OnError.LOG_AND_FALSE ||
550+
e == OnError.LOG_AND_STRING ||
551+
res.includes("get.openwa.dev")
552+
) console.error(res);
553+
/**
554+
* Return res
555+
*/
556+
if(
557+
e == OnError.AS_STRING ||
558+
e == OnError.NOTHING ||
559+
e == OnError.LOG_AND_STRING
560+
) return res
561+
/**
562+
* Return false
563+
*/
564+
if(
565+
e == OnError.LOG_AND_FALSE ||
566+
e == OnError.RETURN_FALSE
567+
) return false
554568
if(e == OnError.RETURN_ERROR) return new Error(res)
555-
if(e == OnError.RETURN_FALSE) return false
556569
if(e == OnError.THROW) throw new Error(res)
557570
}
558571
return res;

0 commit comments

Comments
 (0)