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
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
erp5
Commits
9d4b6f0f
Commit
9d4b6f0f
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
2f58e2e8
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 @
9d4b6f0f
...
@@ -51,19 +51,33 @@ def convertTojIOAPICall(function):
...
@@ -51,19 +51,33 @@ def convertTojIOAPICall(function):
except
Unauthorized
,
e
:
except
Unauthorized
,
e
:
LOG
(
'jIOWebSection'
,
INFO
,
'Converting Unauthorized to Unauthorized error mesage in JSON,'
,
LOG
(
'jIOWebSection'
,
INFO
,
'Converting Unauthorized to Unauthorized error mesage in JSON,'
,
error
=
True
)
error
=
True
)
return
self
.
ERP5Site_logApiErrorAndReturn
(
body
=
self
.
ERP5Site_logApiErrorAndReturn
(
error_code
=
"403"
,
error_code
=
"403"
,
error_message
=
str
(
e
),
error_message
=
str
(
e
),
error_name
=
"Unauthorized"
error_name
=
"Unauthorized"
)
)
self
.
REQUEST
.
response
.
setBody
(
body
,
lock
=
True
)
raise
except
NotFound
,
e
:
except
NotFound
,
e
:
LOG
(
'jIOWebSection'
,
INFO
,
'Converting NotFound to NotFound error mesage in JSON,'
,
LOG
(
'jIOWebSection'
,
INFO
,
'Converting NotFound to NotFound error mesage in JSON,'
,
error
=
True
)
error
=
True
)
return
self
.
ERP5Site_logApiErrorAndReturn
(
body
=
self
.
ERP5Site_logApiErrorAndReturn
(
error_code
=
"404"
,
error_code
=
"404"
,
error_message
=
str
(
e
),
error_message
=
str
(
e
),
error_name
=
"NotFound"
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
return
'%s'
%
retval
wrapper
.
__doc__
=
function
.
__doc__
wrapper
.
__doc__
=
function
.
__doc__
...
...
bt5/erp5_api_style/SkinTemplateItem/portal_skins/erp5_api_style/ERP5Site_logApiErrorAndReturn.py
View file @
9d4b6f0f
...
@@ -7,7 +7,7 @@ error = context.getPortalObject().error_record_module.newContent(
...
@@ -7,7 +7,7 @@ error = context.getPortalObject().error_record_module.newContent(
description
=
str
(
error_message
),
description
=
str
(
error_message
),
text_content
=
str
(
text_content
)
text_content
=
str
(
text_content
)
)
)
container
.
REQUEST
.
RESPONSE
.
setStatus
(
400
)
container
.
REQUEST
.
RESPONSE
.
setStatus
(
error_code
,
lock
=
True
)
# We follow here Paypal api guideline
# We follow here Paypal api guideline
# https://github.com/paypal/api-standards/blob/master/api-style-guide.md#error-schema
# https://github.com/paypal/api-standards/blob/master/api-style-guide.md#error-schema
error_dict
=
{
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