diff options
| author | Shpuld Shpuldson <shpuld@shpposter.club> | 2020-01-26 15:59:59 +0200 |
|---|---|---|
| committer | Shpuld Shpuldson <shpuld@shpposter.club> | 2020-01-26 15:59:59 +0200 |
| commit | c4beac5f894642e64f2818e43697b472b7a70847 (patch) | |
| tree | b5e64b7f4f19b8b15549b0b29e876e8eea724c16 /src/services/errors/errors.js | |
| parent | 7cfe1b05e8d16fcbb6eab3b42f19e464d57ea35b (diff) | |
| parent | b0b0fc403a57dca6837bc99a87c66609156af2b9 (diff) | |
Merge branch 'develop' into feat/emoji-reactions
Diffstat (limited to 'src/services/errors/errors.js')
| -rw-r--r-- | src/services/errors/errors.js | 14 |
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 } |
