Files
edx-platform/lms/djangoapps/program_enrollments/exceptions.py
Kyle McCormick da08357d89 Revert "Revert "Create Python API for program_enrollments: Part IV"" (#21759)
This reverts commit a67b9f70a16a0f16a842aad84754b245a2480b5f,
reinstating commit cf78660ed35712f9bb7c112f70411179070d7382.
The original commit was reverted because I thought I found
bugs in it while verifying it on Stage, but it turns out that
it was simply misconfigured Stage data that causing errors.

The original commit's message has has been copied below:

This commit completes the program_enrollments LMS app
Python API for the time being. It does the following:
* Add bulk-lookup of users by external key in api/reading.py
* Add bulk-writing of program enrollments in api/writing.py
* Move grade-reading to api/grades.py
* Refactor api/linking.py to use api/writing.py
* Refactor signals.py to use api/linking.py
* Update rest_api/v1/views.py to utilize all these changes
* Update linking management command and support tool to use API
* Remove outdated tests from test_models.py
* Misc. cleanup

EDUCATOR-4321
2019-09-24 10:49:54 -04:00

66 lines
1.8 KiB
Python

"""
Exceptions raised by functions exposed by program_enrollments Django app.
"""
from __future__ import absolute_import, unicode_literals
# Every `__init__` here calls empty Exception() constructor.
# pylint: disable=super-init-not-called
class ProgramDoesNotExistException(Exception):
def __init__(self, program_uuid):
self.program_uuid = program_uuid
def __str__(self):
return 'Unable to find catalog program matching uuid {}'.format(self.program_uuid)
class OrganizationDoesNotExistException(Exception):
pass
class ProgramHasNoAuthoringOrganizationException(OrganizationDoesNotExistException):
def __init__(self, program_uuid):
self.program_uuid = program_uuid
def __str__(self):
return (
'Cannot determine authoring organization key for catalog program {}'
).format(self.program_uuid)
class BadOrganizationShortNameException(OrganizationDoesNotExistException):
def __init__(self, organization_short_name):
self.organization_short_name = organization_short_name
def __str__(self):
return 'Unable to find organization for short_name {}'.format(
self.organization_short_name
)
class ProviderDoesNotExistException(Exception):
def __init__(self, organization):
self.organization = organization
def __str__(self):
return 'Unable to find organization for short_name {}'.format(
self.organization.id
)
class ProviderConfigurationException(Exception):
def __init__(self, organization):
self.organization = organization
def __str__(self):
return (
'Multiple active SAML configurations found for organization={}. '
'Expected one.'
).format(self.organization.short_name)