Skip to content

Commit

Permalink
Set exc_info=True for warning log records (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
elacuesta authored Aug 7, 2023
1 parent 72060d2 commit f5d7fc2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions scrapy_playwright/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ async def _create_page(self, request: Request, spider: Spider) -> Page:
"scrapy_request_method": request.method,
"exception": ex,
},
exc_info=True,
)

page.on("close", self._make_close_page_callback(context_name))
Expand Down Expand Up @@ -318,6 +319,7 @@ async def _download_request(self, request: Request, spider: Spider) -> Response:
"scrapy_request_method": request.method,
"exception": ex,
},
exc_info=True,
)
await page.close()
self.stats.inc_value("playwright/page_count/closed")
Expand Down Expand Up @@ -410,6 +412,7 @@ async def _apply_page_methods(self, page: Page, request: Request, spider: Spider
"scrapy_request_method": request.method,
"exception": ex,
},
exc_info=True,
)
else:
pm.result = await _maybe_await(method(*pm.args, **pm.kwargs))
Expand Down Expand Up @@ -560,6 +563,7 @@ async def _request_handler(route: Route, playwright_request: PlaywrightRequest)
"playwright_request_method": playwright_request.method,
"exception": ex,
},
exc_info=True,
)
else:
raise
Expand Down Expand Up @@ -591,6 +595,7 @@ def _attach_page_event_handlers(
"scrapy_request_method": request.method,
"exception": ex,
},
exc_info=True,
)


Expand Down
1 change: 1 addition & 0 deletions tests/test_playwright_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ async def test_route_continue_exception(self, logger):
"playwright_request_method": playwright_request.method,
"exception": ex,
},
exc_info=True,
)

# unknown errors, re-raise
Expand Down

0 comments on commit f5d7fc2

Please sign in to comment.