8000 clearer error message for duplicate email · Michels10/wp-api-python@42cd52f · GitHub
[go: up one dir, main page]

Skip to content

Commit 42cd52f

Browse files
author
derwentx
committed
clearer error message for duplicate email
1 parent d8dc917 commit 42cd52f

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

wordpress/api.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,6 @@ def request_post_mortem(self, response=None):
8888

8989
# import pudb; pudb.set_trace()
9090

91-
if 'code' in response_json or 'message' in response_json:
92-
reason = " - ".join([
93-
str(response_json.get(key)) for key in ['code', 'message', 'data'] \
94-
if key in response_json
95-
])
96-
9791
request_body = {}
9892
request_url = ""
9993
if hasattr(response, 'request'):
@@ -102,6 +96,16 @@ def request_post_mortem(self, response=None):
10296
if hasattr(response.request, 'body'):
10397
request_body = response.request.body
10498

99+
if 'code' in response_json or 'message' in response_json:
100+
reason = " - ".join([
101+
str(response_json.get(key)) for key in ['code', 'message', 'data'] \
102+
if key in response_json
103+
])
104+
105+
if 'code' == 'rest_user_invalid_email':
106+
remedy = "Try checking the email %s doesn't already exist" % \
107+
request_body.get('email')
108+
105109
response_headers = {}
106110
if hasattr(response, 'headers'):
107111
response_headers = response.headers

0 commit comments

Comments
 (0)
0