(self, exc: Exception, identity: Identity | None = None)
| 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"]) |
no test coverage detected