Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [AXM-1305] handle sync groups errors #196

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions credentials/apps/badges/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _

from credentials.apps.badges.exceptions import BadgeProviderError
from credentials.apps.badges.admin_forms import (
BadgePenaltyForm,
BadgeRequirementForm,
Expand Down Expand Up @@ -576,11 +577,15 @@ def sync_groups(self, request, queryset):
"""
site = get_current_site(request)
for api_config in queryset:
call_command(
"sync_accredible_groups",
api_config_id=api_config.id,
site_id=site.id,
)
try:
call_command(
"sync_accredible_groups",
api_config_id=api_config.id,
site_id=site.id,
)
except BadgeProviderError as exc:
messages.set_level(request, messages.ERROR)
messages.error(request, _("Failed to sync groups for API config: {}. {}").format(api_config.name, exc))

messages.success(request, _("Accredible groups were successfully updated."))

Expand Down
4 changes: 2 additions & 2 deletions credentials/apps/badges/base_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def _raise_for_error(self, response):
try:
response.raise_for_status()
except HTTPError:
logger.error(f"Error while processing request: {response.status_code} - {response.text}")
raise BadgeProviderError(f"{self.PROVIDER_NAME} API:{response.text}({response.status_code})")
logger.error(f"Error while processing {self.PROVIDER_NAME} request: {response.status_code} - {response.text}")
raise BadgeProviderError(f"{response.text} Status({response.status_code})")

@property
def base_api_url(self):
Expand Down
Loading