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
Open
Conversation
Collaborator
andrzejewsky
commented
Apr 3, 2020
- I'm confirming that if i made any changes to public APIs or exposed any public APIs they are doccumented.
filrak
reviewed
Apr 3, 2020
Contributor
There was a problem hiding this comment.
I like the idea but I don't like the solution. below few concerns from my side;
- 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
- How you want to handle i18n?
- What if someone wants to change the error message for specific shop (for example they want to add link to support)
- Wouldn't it be better to just return an
errorobject from specific functions in factory params instead of having thisconvertErrorfunction? 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 }
}
patzick
reviewed
Apr 6, 2020
| const errors = ref({};) | ||
|
|
||
|
|
||
| const search = async (params) => { |
Contributor
There was a problem hiding this comment.
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); |
Contributor
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.