Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PizzaPalace
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TheJoeCoder
PizzaPalace
Commits
e7acd650
Verified
Commit
e7acd650
authored
Jun 29, 2023
by
TheJoeCoder
Browse files
Options
Downloads
Patches
Plain Diff
[Server] Full Traceback on webhook fail
parent
e41b44d0
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/app.py
+23
-3
23 additions, 3 deletions
server/app.py
with
23 additions
and
3 deletions
server/app.py
+
23
−
3
View file @
e7acd650
...
@@ -25,6 +25,21 @@ open_carts["test"] = {
...
@@ -25,6 +25,21 @@ open_carts["test"] = {
"
items
"
:
[]
"
items
"
:
[]
}
}
# Full stack trace function
# from https://stackoverflow.com/questions/6086976/how-to-get-a-complete-exception-stack-trace-in-python/16589622#16589622
def
full_stack
():
import
traceback
,
sys
exc
=
sys
.
exc_info
()[
0
]
stack
=
traceback
.
extract_stack
()[:
-
1
]
# last one would be full_stack()
if
exc
is
not
None
:
# i.e. an exception is present
del
stack
[
-
1
]
# remove call of full_stack, the printed exception
# will contain the caught exception caller instead
trc
=
'
Traceback (most recent call last):
\n
'
stackstr
=
trc
+
''
.
join
(
traceback
.
format_list
(
stack
))
if
exc
is
not
None
:
stackstr
+=
'
'
+
traceback
.
format_exc
().
lstrip
(
trc
)
return
stackstr
def
get_cart
(
uid
,
key
):
def
get_cart
(
uid
,
key
):
if
(
uid
==
None
or
key
==
None
or
uid
not
in
open_carts
or
open_carts
[
uid
][
"
key
"
]
!=
key
):
if
(
uid
==
None
or
key
==
None
or
uid
not
in
open_carts
or
open_carts
[
uid
][
"
key
"
]
!=
key
):
return
None
return
None
...
@@ -200,9 +215,14 @@ def confirm_order_cart():
...
@@ -200,9 +215,14 @@ def confirm_order_cart():
"
username
"
:
"
PizzaBot
"
,
"
username
"
:
"
PizzaBot
"
,
"
content
"
:
config
.
webhook_content_prepend
+
str
(
order_id
)
"
content
"
:
config
.
webhook_content_prepend
+
str
(
order_id
)
}
}
try
:
webhook_response
=
requests
.
post
(
config
.
webhook_url
,
json
=
webhook_data
)
webhook_response
=
requests
.
post
(
config
.
webhook_url
,
json
=
webhook_data
)
if
(
webhook_response
.
status_code
!=
200
):
if
(
webhook_response
.
status_code
!=
200
):
logger
.
error
(
"
Webhook failed with status code
"
+
str
(
webhook_response
.
status_code
))
logger
.
error
(
"
Webhook failed with status code
"
+
str
(
webhook_response
.
status_code
))
except
:
except_text
=
full_stack
()
logger
.
error
(
"
Webhook failed with exception
"
)
logger
.
debug
(
except_text
)
# Remove cart from existing carts
# Remove cart from existing carts
del
open_carts
[
cart_id
]
del
open_carts
[
cart_id
]
# Return order ID
# Return order ID
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment