Skip to content

Commit 8b5a4b3

Browse files
committed
Add more error handling to be able to troubleshoot issues.
1 parent 457fb59 commit 8b5a4b3

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "capture-template",
3-
"version": "1.0.4",
3+
"version": "1.0.5",
44
"description": "This library is responsible for expanding a template web page and then capturing it PNG or PDF.",
55
"main": "build/index.js",
66
"types": "build/index.d.ts",

src/web-page-renderer.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,21 @@ export class WebPageRenderer implements IWebPageRenderer {
8686
throw new Error("Nightmare crashed " + evt.toString());
8787
});
8888

89+
this.nightmare.on('page', (type: string, message: string, stack: any) => {
90+
if (type === "error") {
91+
console.error("Browser page error: " + message);
92+
console.error(stack);
93+
}
94+
});
95+
96+
this.nightmare.on("did-fail-load", (event: any, errorCode: number, errorDescription: string, validatedURL: string, isMainFrame: boolean) => {
97+
console.error("Browser page failed to load.");
98+
console.error("Error code: " + errorCode);
99+
console.error("Error description: " + errorDescription);
100+
console.error("Validated URL: " + validatedURL);
101+
console.error("Is main frame: " + isMainFrame);
102+
});
103+
89104
this.nightmare.on('console', (type: string, message: string) => {
90105

91106
if (type === 'log') {

0 commit comments

Comments
 (0)