feat(chalice): errors_helper
This commit is contained in:
parent
c29423f0b6
commit
c692790a9e
1 changed files with 14 additions and 0 deletions
14
api/chalicelib/utils/errors_helper.py
Normal file
14
api/chalicelib/utils/errors_helper.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
from chalicelib.core import sourcemaps
|
||||
|
||||
|
||||
def format_first_stack_frame(error):
|
||||
error["stack"] = sourcemaps.format_payload(error.pop("payload"), truncate_to_first=True)
|
||||
for s in error["stack"]:
|
||||
for c in s.get("context", []):
|
||||
for sci, sc in enumerate(c):
|
||||
if isinstance(sc, str) and len(sc) > 1000:
|
||||
c[sci] = sc[:1000]
|
||||
# convert bytes to string:
|
||||
if isinstance(s["filename"], bytes):
|
||||
s["filename"] = s["filename"].decode("utf-8")
|
||||
return error
|
||||
Loading…
Add table
Reference in a new issue