aboutsummaryrefslogtreecommitdiff
path: root/src/services/api/api.service.js
diff options
context:
space:
mode:
authorHJ <30-hj@users.noreply.git.pleroma.social>2019-08-06 18:03:32 +0000
committerHJ <30-hj@users.noreply.git.pleroma.social>2019-08-06 18:03:32 +0000
commit17dc7357d5036681b346f745190204e213c0ef8c (patch)
tree33966f59ce8dbf4f75afb43bbb24ec860ff98aaf /src/services/api/api.service.js
parent0e6489d84019ac146af1dd5df9f1db548b4df5ac (diff)
parent4fc27414d25d719991d2368740c5ffea67af907d (diff)
Merge branch 'issue-617' into 'develop'
Handle JSONified errors while registering Closes #617 See merge request pleroma/pleroma-fe!888
Diffstat (limited to 'src/services/api/api.service.js')
-rw-r--r--src/services/api/api.service.js9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js
index d4ad1c4e..84616dd1 100644
--- a/src/services/api/api.service.js
+++ b/src/services/api/api.service.js
@@ -1,7 +1,7 @@
import { each, map, concat, last } from 'lodash'
import { parseStatus, parseUser, parseNotification, parseAttachment } from '../entity_normalizer/entity_normalizer.service.js'
import 'whatwg-fetch'
-import { StatusCodeError } from '../errors/errors'
+import { RegistrationError, StatusCodeError } from '../errors/errors'
/* eslint-env browser */
const EXTERNAL_PROFILE_URL = '/api/externalprofile/show.json'
@@ -199,12 +199,11 @@ const register = ({ params, credentials }) => {
...rest
})
})
- .then((response) => [response.ok, response])
- .then(([ok, response]) => {
- if (ok) {
+ .then((response) => {
+ if (response.ok) {
return response.json()
} else {
- return response.json().then((error) => { throw new Error(error) })
+ return response.json().then((error) => { throw new RegistrationError(error) })
}
})
}