Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved share extension error handling #895

Merged
merged 2 commits into from
Apr 4, 2024

Conversation

michalrentka
Copy link
Contributor

Fixes #893, also in #891 I missed a case, where metadata editing is enabled, but file editing is disabled, in that case, we'd get "unknown" error in share extension too. This time we show proper error all the time. Share extension also cleans up after itself if there is an error, so we don't have any items which shouldn't exist.

@michalrentka michalrentka requested a review from mvasilak April 3, 2024 14:33
Copy link
Contributor

@mvasilak mvasilak left a comment

Choose a reason for hiding this comment

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

Looks good, a couple of suggestions/questions.

Regarding switch where cases are specific, it might be better to not use default, but rather explicit cases, so that build complains when a new case is omitted.

If an item shouldn't be created when upload fails, why not perform them in reverse order, i.e try uploading, and if this succeeds, create the item. Is there some edge case I'm not aware of, that is covered by the current workflow?

@michalrentka
Copy link
Contributor Author

If an item shouldn't be created when upload fails, why not perform them in reverse order, i.e try uploading, and if this succeeds, create the item. Is there some edge case I'm not aware of, that is covered by the current workflow?

So our API requires an item created beforehand, so I have to create an item, submit it to API, then authorize an upload and finally upload the file. So if authorization fails I have to delete the file afterwards.

@michalrentka
Copy link
Contributor Author

Regarding switch where cases are specific, it might be better to not use default, but rather explicit cases, so that build complains when a new case is omitted.

Agreed, I usually try to do that, fixed it here: 64be7e4.

@michalrentka michalrentka merged commit 0cc034c into zotero:master Apr 4, 2024
1 check passed
@michalrentka michalrentka deleted the shareext_fix branch April 4, 2024 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Share extension shouldn't create new item if it doesn't have necessary access rights
2 participants