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: Handle PatchFailed error in PATCH request #139

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

Conversation

7shi
Copy link

@7shi 7shi commented Nov 30, 2024

Currently, PatchFailed errors in PATCH requests are not properly handled, causing uncaught promise rejections:

plugin:obsidian-local-rest-api:57202 Uncaught (in promise) PatchFailed
    at applyPatch2 (plugin:obsidian-local-rest-api:57202:19)
    at RequestHandler.eval (plugin:obsidian-local-rest-api:57821:60)
    at Generator.next (<anonymous>)
    at fulfilled (plugin:obsidian-local-rest-api:70:24)

This PR adds error handling to properly catch and return these errors to the client, including the specific reason for patch failures in the API response.

The change wraps the applyPatch call in a try-catch block and uses the existing returnCannedResponse method to return a consistent error format.

@Shtooth
Copy link

Shtooth commented Dec 30, 2024

Hello guys!
Any update on this?
It is really problematic to develop something that uses this as you need to completely restart the API each time you fail a request.

@coddingtonbear
Copy link
Owner

Sorry-- I have very limited time right now owing to it being the holidays, but I imagine I'll have a chance to look at this next week.

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.

3 participants