MCPcopy Create free account
hub / github.com/getsentry/sentry / raise_error

Method raise_error

src/sentry/integrations/github/issues.py:47–78  ·  view source on GitHub ↗
(self, exc: Exception, identity: Identity | None = None)

Source from the content-addressed store, hash-verified

45 return login, f"{name} (@{login})" if name else login
46
47 def raise_error(self, exc: Exception, identity: Identity | None = None) -> NoReturn:
48 if isinstance(exc, ApiError):
49 if exc.code == 422:
50 invalid_fields = {}
51 if exc.json is not None:
52 for e in exc.json.get("errors", []):
53 field = e.get("field", "unknown field")
54 code = e.get("code", "invalid")
55 value = e.get("value", "unknown value")
56
57 invalid_fields[field] = f"Got {code} value: {value} for field: {field}"
58 raise IntegrationFormError(invalid_fields) from exc
59 raise IntegrationFormError(
60 {"detail": "Some given field was misconfigured"}
61 ) from exc
62 elif exc.code == 410:
63 raise IntegrationConfigurationError(
64 "Issues are disabled for this repository, please check your repository permissions"
65 ) from exc
66 elif exc.code == 404:
67 raise IntegrationResourceNotFoundError from exc
68 elif exc.code == 403:
69 if exc.json is not None:
70 detail = exc.json.get("message")
71 if detail:
72 raise IntegrationConfigurationError(detail) from exc
73
74 raise IntegrationConfigurationError(
75 "You are not authorized to create issues in this repository. Please check your repository permissions."
76 ) from exc
77
78 raise super().raise_error(exc=exc, identity=identity)
79
80 def make_external_key(self, data: Mapping[str, Any]) -> str:
81 return "{}#{}".format(data["repo"], data["key"])

Callers 15

create_issueMethod · 0.95
get_allowed_assigneesMethod · 0.95
get_repo_labelsMethod · 0.95
search_repo_labelsMethod · 0.95
sync_status_outboundMethod · 0.45
_validate_repoMethod · 0.45
fetch_recent_commitsMethod · 0.45
sync_status_outboundMethod · 0.45
get_repository_dataMethod · 0.45

Calls 3

getMethod · 0.65

Tested by

no test coverage detected