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

fix: synchronous errors from addPhoto #1016

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

gmaclennan
Copy link
Member

Other draft observation store actions throw an error synchronously if there is no current draft observation, however the addPhoto action was defined as an asynchronous function, so the error from asserting a draft exists first was thrown asynchronously.

This PR changes the implementation of addPhoto so that the initial addition of an empty attachment (before photo processing) is done synchronously, so that the error from a draft not existing is thrown synchronously. This matches the behaviour of the other actions.

It's not necessary to return a promise from addPhoto, since we don't have any code that uses this promise, but it could be useful in the future (the promise resolves when all the photo versions are created). It is important to catch any errors from photo processing, to avoid the risk of an uncaught error.

I'm open to a preference to just return void from addPhoto rather than Promise<void>.

@gmaclennan gmaclennan self-assigned this Mar 4, 2025
@gmaclennan gmaclennan requested a review from ErikSin March 4, 2025 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant