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

[RFC ] Errors handling#341

Open
andrzejewsky wants to merge 1 commit into
masterfrom
errorsHandling
Open

[RFC ] Errors handling#341
andrzejewsky wants to merge 1 commit into
masterfrom
errorsHandling

Conversation

@andrzejewsky
Copy link
Copy Markdown
Collaborator

  • I'm confirming that if i made any changes to public APIs or exposed any public APIs they are doccumented.

Copy link
Copy Markdown
Contributor

@filrak filrak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea but I don't like the solution. below few concerns from my side;

  1. I would suggest to have a default, generic errors in factories like "Something went wrong with searching the products" that can be extended with specific cases for the integration
  2. How you want to handle i18n?
  3. What if someone wants to change the error message for specific shop (for example they want to add link to support)
  4. Wouldn't it be better to just return an error object from specific functions in factory params instead of having this convertError function? Seems more natural to me to have that in one place and doesn't involve any underlying magic - we could have something like this
const factoryParams = {
  searchProducts: async (params) => {
    try {
     const product =  await getProductsFromApi(params);
    } catch (err) {
      if (err === "sth") const error = 'friendly error"
    }
    return { products, error }
  }

const errors = ref({};)


const search = async (params) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const search = async (params) => {
const search = async (params) => {
errors.searchProducts = null

try {
products.value = factoryParams.searchProducts(params);
} catch (err) {
errors.searchProducts = factoryParams.convertError(err);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

params should also be passed to the converError in order to supply additional information about context of this method used.

If we execute one method multiple times we will lose all errors except the one from last execution

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants