Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Titouan Soulard
erp5
Commits
edf445e7
Commit
edf445e7
authored
Oct 10, 2023
by
Titouan Soulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_api_style: report BadRequest errors in JSON
parent
bb75ce41
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
3 deletions
+17
-3
bt5/erp5_api_style/DocumentTemplateItem/portal_components/document.erp5.jIOWebSection.py
...lateItem/portal_components/document.erp5.jIOWebSection.py
+16
-2
bt5/erp5_api_style/SkinTemplateItem/portal_skins/erp5_api_style/ERP5Site_logApiErrorAndReturn.py
...tal_skins/erp5_api_style/ERP5Site_logApiErrorAndReturn.py
+1
-1
No files found.
bt5/erp5_api_style/DocumentTemplateItem/portal_components/document.erp5.jIOWebSection.py
View file @
edf445e7
...
...
@@ -51,19 +51,33 @@ def convertTojIOAPICall(function):
except
Unauthorized
,
e
:
LOG
(
'jIOWebSection'
,
INFO
,
'Converting Unauthorized to Unauthorized error mesage in JSON,'
,
error
=
True
)
return
self
.
ERP5Site_logApiErrorAndReturn
(
body
=
self
.
ERP5Site_logApiErrorAndReturn
(
error_code
=
"403"
,
error_message
=
str
(
e
),
error_name
=
"Unauthorized"
)
self
.
REQUEST
.
response
.
setBody
(
body
,
lock
=
True
)
raise
except
NotFound
,
e
:
LOG
(
'jIOWebSection'
,
INFO
,
'Converting NotFound to NotFound error mesage in JSON,'
,
error
=
True
)
return
self
.
ERP5Site_logApiErrorAndReturn
(
body
=
self
.
ERP5Site_logApiErrorAndReturn
(
error_code
=
"404"
,
error_message
=
str
(
e
),
error_name
=
"NotFound"
)
self
.
REQUEST
.
response
.
setBody
(
body
,
lock
=
True
)
raise
except
:
LOG
(
'jIOWebSection'
,
INFO
,
'Converting Error to InternalError message in JSON,'
,
error
=
True
)
body
=
self
.
ERP5Site_logApiErrorAndReturn
(
error_code
=
"500"
,
error_message
=
"Internal Server Error"
,
error_name
=
"InternalError"
)
self
.
REQUEST
.
response
.
setBody
(
body
,
lock
=
True
)
raise
return
'%s'
%
retval
wrapper
.
__doc__
=
function
.
__doc__
...
...
bt5/erp5_api_style/SkinTemplateItem/portal_skins/erp5_api_style/ERP5Site_logApiErrorAndReturn.py
View file @
edf445e7
...
...
@@ -7,7 +7,7 @@ error = context.getPortalObject().error_record_module.newContent(
description
=
str
(
error_message
),
text_content
=
str
(
text_content
)
)
container
.
REQUEST
.
RESPONSE
.
setStatus
(
400
)
container
.
REQUEST
.
RESPONSE
.
setStatus
(
error_code
,
lock
=
True
)
# We follow here Paypal api guideline
# https://github.com/paypal/api-standards/blob/master/api-style-guide.md#error-schema
error_dict
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment