Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
code-review-graph/code_review_graph/errors.py at staging · tirth8205/code-review-graph · GitHub
Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Events
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
tirth8205
code-review-graph
Repository navigation
Code
Issues
102
(102)
Pull requests
89
(89)
Discussions
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
staging
Breadcrumbs
code-review-graph
/
code_review_graph
/
errors.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
80 lines (58 loc) · 2.78 KB
staging
Breadcrumbs
code-review-graph
/
code_review_graph
/
errors.py
Copy path
Top
File metadata and controls
Code
Blame
80 lines (58 loc) · 2.78 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
"""Errors the CLI is expected to report as one line, never as a traceback.
Every exception here means "the tool cannot do the job, and it knows why".
``cli.main`` turns each of them into the house failure style — a single
``Error: ...`` line on stderr and exit 1 — so the message is the only thing
the user sees. The MCP tools turn them into ``{"status": "error", ...}``.
Keep the ``str()`` of each one short enough to read on a terminal line and
specific enough to act on: what is wrong, where, and what to do about it.
"""
from
__future__
import
annotations
import
sqlite3
class
CodeReviewGraphError
(
Exception
):
"""Base class for every self-explaining failure in this package."""
class
GraphStoreError
(
CodeReviewGraphError
):
"""The graph database cannot be opened, read, or written.
Raised for a corrupt or foreign ``graph.db``, one written by a newer
schema than this installation understands, and for a data directory the
process may not write to.
"""
class
GraphRootMismatchError
(
GraphStoreError
):
"""The graph on disk was built for a different repository root.
Answering from it would serve one repository another repository's
symbols, so every consumer refuses instead.
"""
class
ChangeDiscoveryError
(
CodeReviewGraphError
,
RuntimeError
):
"""The set of changed files or lines could not be determined.
Distinct from "there are no changes" on purpose: a review gate keyed on
an all-clear must not pass a pull request that was never looked at.
Raised when the VCS binary is missing, times out, or fails.
Also a ``RuntimeError``: ``get_changed_files(strict=True)`` has raised
one since before this class existed, and callers that catch
``RuntimeError`` there keep working.
"""
# SQLite's answer to a writer that waited out ``busy_timeout`` is
# ``OperationalError: database is locked``. Nothing between there and the
# process boundary used to catch it, so a user whose watcher happened to be
# mid-update saw twenty lines of internal traceback.
#
# Contention is emphatically not one of the failures above. A graph another
# process is writing is healthy; it needs a second try, not the rebuild a
# :class:`GraphStoreError` prescribes. The two are told apart here, once, so
# that no caller can quietly relabel one as the other.
_LOCK_ERRORS
=
(
"database is locked"
,
"database table is locked"
,
"database schema is locked"
,
)
def
is_lock_error
(
exc
:
BaseException
)
->
bool
:
"""True when SQLite refused because another process holds the write lock."""
return
isinstance
(
exc
,
sqlite3
.
OperationalError
)
and
any
(
needle
in
str
(
exc
).
lower
()
for
needle
in
_LOCK_ERRORS
)
__all__
=
[
"ChangeDiscoveryError"
,
"CodeReviewGraphError"
,
"GraphRootMismatchError"
,
"GraphStoreError"
,
"is_lock_error"
,
]
You can’t perform that action at this time.