ソースを参照

refactor(webapp): make digestError asynchronous

Peter Thomassen 2 年 前
コミット
6aef0b321e

+ 1 - 1
www/webapp/src/components/DonateDirectDebitForm.vue

@@ -180,7 +180,7 @@
           this.mref = response.data.mref;
           this.done = true;
         } catch (ex) {
-          let errors = digestError(ex);
+          let errors = await digestError(ex);
           for (const c in errors) {
             if (c === 'email') {
               this.email_errors = errors[c];

+ 3 - 3
www/webapp/src/utils.js

@@ -35,7 +35,7 @@ export async function withWorking(errorHandler, action, ...params) {
   }
 }
 
-function _digestError(error, app) {
+async function _digestError(error, app) {
   if (error.response) {
     // The request was made and the server responded with a status code
     // that falls out of the range of 2xx
@@ -92,8 +92,8 @@ function _digestError(error, app) {
  * @param {Exception} error - Exception that has a response attribute.
  * @param {object} [component] - Vue component, required to allow the error to cause a redirect.
  */
-export function digestError(error, component) {
-  let e = _digestError(error, component);
+export async function digestError(error, component) {
+  let e = await _digestError(error, component);
   if (e.constructor === Array) {
     return {undefined: e};
   } else {

+ 1 - 1
www/webapp/src/views/ChangeEmail.vue

@@ -149,7 +149,7 @@
           });
           this.done = true;
         } catch (ex) {
-          let errors = digestError(ex, this);
+          let errors = await digestError(ex, this);
           for (const c in errors) {
             this.errors.push(...errors[c]);
           }

+ 1 - 1
www/webapp/src/views/Confirmation.vue

@@ -102,7 +102,7 @@
           this.post_response = await HTTP.post(`v/${action}/${this.$route.params.code}/`, this.post_payload);
           this.success = true
         } catch (ex) {
-          let errors = digestError(ex);
+          let errors = await digestError(ex);
           this.post_response = ex.response
           for (const c in errors) {
             this.errors.push(...errors[c])

+ 1 - 1
www/webapp/src/views/Console/TOTPVerifyDialog.vue

@@ -137,7 +137,7 @@ export default {
         );
         this.successDetail = res.data.detail;
       } catch (ex) {
-        let errors = digestError(ex);
+        let errors = await digestError(ex);
         for (const c in errors) {
           this.errors.push(...errors[c]);
         }

+ 2 - 2
www/webapp/src/views/CrudList.vue

@@ -617,9 +617,9 @@ export default {
      * Handle the error e by displaying it to the user.
      * @param e
      */
-    error(ex) {
+    async error(ex) {
       this.errors.splice(0, this.errors.length);
-      let errors = digestError(ex, this);
+      let errors = await digestError(ex, this);
       for (const c in errors) {
         if (this.columns[c] !== undefined) {
           this.columns[c].createErrors = errors[c];

+ 1 - 1
www/webapp/src/views/DeleteAccount.vue

@@ -121,7 +121,7 @@
           });
           this.done = true;
         } catch (ex) {
-          let errors = digestError(ex, this);
+          let errors = await digestError(ex, this);
           for (const c in errors) {
             this.errors.push(...errors[c])
           }

+ 2 - 2
www/webapp/src/views/DynSetup.vue

@@ -237,10 +237,10 @@
           this.errorHandler(error);
         }
       },
-      errorHandler(ex) {
+      async errorHandler(ex) {
         if (ex.response && ex.response.status === 404)
           return;
-        let errors = digestError(ex, this);
+        let errors = await digestError(ex, this);
         for (const c in errors) {
           this.errors.push(...errors[c])
         }

+ 1 - 1
www/webapp/src/views/Login.vue

@@ -130,7 +130,7 @@ export default {
           this.$router.replace({ name: 'domains' });
         }
       } catch (ex) {
-        let errors = digestError(ex, this);
+        let errors = await digestError(ex, this);
         for (const c in errors) {
           if (c === 'email') {
             this.email_errors = errors.email;

+ 1 - 1
www/webapp/src/views/MFA.vue

@@ -123,7 +123,7 @@ export default {
           this.$router.replace({ name: 'domains' });
         }
       } catch (ex) {
-        let errors = digestError(ex);
+        let errors = await digestError(ex);
         for (const c in errors) {
           this.errors.push(...errors[c]);
         }

+ 1 - 1
www/webapp/src/views/ResetPassword.vue

@@ -191,7 +191,7 @@
           this.done = true;
         } catch (ex) {
           this.getCaptcha(true);
-          let errors = digestError(ex);
+          let errors = await digestError(ex);
           for (const c in errors) {
             if (c === 'captcha') {
               this.captcha_errors.push(...(errors[c]['non_field_errors'] ?? []));

+ 1 - 1
www/webapp/src/views/SignUp.vue

@@ -282,7 +282,7 @@
           this.$router.push({name: 'welcome', params: domain !== '' ? {domain: domain} : {}});
         } catch (ex) {
           this.getCaptcha(true);
-          let errors = digestError(ex);
+          let errors = await digestError(ex);
           for (const c in errors) {
             if (c === undefined) {
               this.errors.push(...errors[c]);