Skip to content

Commit cbb5ff9

Browse files
authored
Merge pull request #1 from surquest/fix
Fixing issue of not callable coroutine.
2 parents a7a242c + 2ade4bf commit cbb5ff9

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "surquest-fastapi-utils"
7-
version = "0.2.0rc1"
7+
version = "0.2.1"
88
description = "This project provides collection of utilities for FastAPI framework as: Catcher, Middleware, etc."
99
authors = [
1010
{name= "Michal Švarc", email= "michal.svarc@surquest.com"}

src/surquest/fastapi/utils/GCP/catcher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121

2222

2323
async def catch_validation_exceptions(request: Request, exc):
24-
return Catcher.catch_validation_error(request, exc)
24+
return await Catcher.catch_validation_error(request, exc)
2525

2626

2727
async def catch_http_exceptions(request: Request, exc):
28-
return Catcher.catch_http_exception(request, exc)
28+
return await Catcher.catch_http_exception(request, exc)
2929

3030

3131
class Catcher:

src/surquest/fastapi/utils/GCP/formatter.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,15 @@ def format(self, record) -> str:
107107
# if log record is an error add @type attribute to comply with GCP Error Reporting format
108108
if record.levelno >= logging.ERROR:
109109

110+
tb = [] # empty traceback
111+
if "ctx" in log and "traceback" in log["ctx"]:
112+
# get traceback from log record if present
113+
tb = log["ctx"]["traceback"]
114+
110115
log["@type"] = self.GCP_LOG_TYPE
111116
log["message"] = self.format_stack_trace(
112117
message=log["message"],
113-
traceback=log["ctx"]["traceback"]
118+
traceback=tb
114119
)
115120
log["serviceContext"] = self.get_service_context()
116121
log["context"] = {

0 commit comments

Comments
 (0)