aboutsummaryrefslogtreecommitdiff
path: root/src/services/errors/errors.js
diff options
context:
space:
mode:
authorShpuld Shpuldson <shpuld@shpposter.club>2020-01-26 15:59:59 +0200
committerShpuld Shpuldson <shpuld@shpposter.club>2020-01-26 15:59:59 +0200
commitc4beac5f894642e64f2818e43697b472b7a70847 (patch)
treeb5e64b7f4f19b8b15549b0b29e876e8eea724c16 /src/services/errors/errors.js
parent7cfe1b05e8d16fcbb6eab3b42f19e464d57ea35b (diff)
parentb0b0fc403a57dca6837bc99a87c66609156af2b9 (diff)
Merge branch 'develop' into feat/emoji-reactions
Diffstat (limited to 'src/services/errors/errors.js')
-rw-r--r--src/services/errors/errors.js14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/services/errors/errors.js b/src/services/errors/errors.js
index 590552da..d4cf9132 100644
--- a/src/services/errors/errors.js
+++ b/src/services/errors/errors.js
@@ -32,12 +32,18 @@ export class RegistrationError extends Error {
}
if (typeof error === 'object') {
+ const errorContents = JSON.parse(error.error)
+ // keys will have the property that has the error, for example 'ap_id',
+ // 'email' or 'captcha', the value will be an array of its error
+ // like "ap_id": ["has been taken"] or "captcha": ["Invalid CAPTCHA"]
+
// replace ap_id with username
- if (error.ap_id) {
- error.username = error.ap_id
- delete error.ap_id
+ if (errorContents.ap_id) {
+ errorContents.username = errorContents.ap_id
+ delete errorContents.ap_id
}
- this.message = humanizeErrors(error)
+
+ this.message = humanizeErrors(errorContents)
} else {
this.message = error
}