Skip to content

docs: Make example run smoothly by catching exception#482

Open
szabgab wants to merge 1 commit into
FalkorDB:mainfrom
szabgab:exception
Open

docs: Make example run smoothly by catching exception#482
szabgab wants to merge 1 commit 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
    • Enhanced Python getting started guide with improved error handling in code examples, increasing script stability and reliability.

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

📝 Walkthrough

Walkthrough

The PR updates the Python "Getting Started" code example in the documentation by wrapping the g.delete() call in a try/except block. This allows the snippet to proceed safely when the MotoGP graph doesn't exist on the first run, rather than failing unconditionally.

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 to handle cases where the graph doesn't exist yet, allowing the Getting Started script to run successfully on first execution.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A rabbit hops through docs with glee,
Wrapping deletes in try/except, you see!
No more stumbles when graphs aren't there,
The getting started guide now shows more care! 📖✨

🚥 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 directly and accurately describes the main change: adding exception handling to make the example code run smoothly.
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

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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