Skip to content

docs: Make example run smoothly by catching exception#482

Open
szabgab wants to merge 2 commits into
FalkorDB:mainfrom
szabgab:exception
Open

docs: Make example run smoothly by catching exception#482
szabgab wants to merge 2 commits into
FalkorDB:mainfrom
szabgab:exception

Conversation

@szabgab
Copy link
Copy Markdown

@szabgab szabgab commented May 14, 2026

g.delete() raises exception if the graph does not exist.

Having such an example on the front page is not very welcoming. Catching the exception and sweeping under the carpet solves this.

Reported as #481

Summary by CodeRabbit

  • Documentation
    • Updated the Python "Getting Started" snippet to improve error handling in the example so the script continues gracefully if the sample graph is absent, making the guide more stable and user-friendly.

Review Change Stack

`g.delete()` raises exception if the graph does not exist.

Having such an example on the front page is not very welcoming.
Catching the exception and sweeping under the carpet solves this.

Reported as FalkorDB#481
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0b5e951c-2560-48ef-9fa8-1144eb8a1f3b

📥 Commits

Reviewing files that changed from the base of the PR and between 863b5e8 and 6937c07.

📒 Files selected for processing (1)
  • index.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • index.md

📝 Walkthrough

Walkthrough

The PR updates the Python "Getting Started" example to wrap g.delete() in a try/except redis.exceptions.ResponseError, allowing the snippet to continue when the MotoGP graph is absent.

Changes

Python Getting Started Example

Layer / File(s) Summary
Python getting started code snippet error handling
index.md
The g.delete() call is wrapped in a try/except block catching redis.exceptions.ResponseError, so the Getting Started script proceeds when the MotoGP graph doesn't exist.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 I hopped through docs at break of day,
Wrapped g.delete() so errors stay away,
Now first runs pass without a scare,
The MotoGP graph can vanish—no despair,
Happy hops and docs that play!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: wrapping a delete operation in exception handling to allow the example to run smoothly without errors.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
index.md (1)

77-81: ⚡ Quick win

Narrow the exception handling to avoid masking real failures.

This catches all runtime errors, so unrelated issues can be silently ignored. Handle only the expected “graph missing” case and re-raise everything else.

Proposed change
 try:
     g.delete()
-except Exception:
-    # Graph doesn't exist yet, which is fine
-    pass
+except Exception as e:
+    # Ignore only the expected "graph does not exist" case.
+    if "does not exist" in str(e).lower():
+        pass
+    else:
+        raise
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@index.md` around lines 77 - 81, The current try/except around g.delete()
swallows all exceptions; narrow it to only ignore the expected "graph missing"
error and re-raise all others. Replace the bare except with either a catch of
the specific error class thrown when the graph does not exist (e.g.,
GraphNotFoundError, KeyError, or FileNotFoundError depending on the graph
implementation) or use "except Exception as e:" and inspect e (error type or
message) to only pass for the missing-graph case and raise for anything else;
reference the g.delete() call and variable g when making this change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@index.md`:
- Around line 77-81: The current try/except around g.delete() swallows all
exceptions; narrow it to only ignore the expected "graph missing" error and
re-raise all others. Replace the bare except with either a catch of the specific
error class thrown when the graph does not exist (e.g., GraphNotFoundError,
KeyError, or FileNotFoundError depending on the graph implementation) or use
"except Exception as e:" and inspect e (error type or message) to only pass for
the missing-graph case and raise for anything else; reference the g.delete()
call and variable g when making this change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 10a530fa-2b98-4c1f-8d96-8d69d3688b74

📥 Commits

Reviewing files that changed from the base of the PR and between f7229b8 and 863b5e8.

📒 Files selected for processing (1)
  • index.md

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