Skip to content
This repository was archived by the owner on May 21, 2020. It is now read-only.
This repository was archived by the owner on May 21, 2020. It is now read-only.

[Core] Error handling #293

@andrzejewsky

Description

@andrzejewsky
  1. Composables return errors object that contains all of errors under the keys that are defined in the core.
  2. A developer can use composable function and the errors field in the theme and is able to react on particular error itself.

example of composable function:

const useUser = () => {
 connst errors = ref({});

 const registerUser = () => {
  try {
    // .. 
   } catch (e) {
    errors.register = e;
   }
 };
 const loginUser = () => {
  try {
    // .. 
   } catch (e) {
    errors.login = e;
   }
  }

 return {
   errors,
   registerUser,
   loginUser
 };
}

now in the theme you can react on each error type:

<template>
 <div>
     <div v-if="errors.register">There was a problem with registering: {{ errors.register }}</div>
     <div v-if="errors.login">There was a problem with login: {{errors.login }}</div>
  </div>
</template>

 setup() {
   const { errors, ... } = useUser()

   // ...

  return { errors };
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions