# -*- coding: utf-8 -*-
from rest_framework import status
from rest_framework.exceptions import APIException
[docs]class AsnNotFoundError(APIException):
status_code = status.HTTP_404_NOT_FOUND
def __init__(self, msg):
self.detail = u'ASN %s do not exist.' % (msg)
[docs]class AsnError(APIException):
status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
def __init__(self, msg):
self.detail = msg
[docs]class AsnAssociatedToEquipmentError(APIException):
status_code = status.HTTP_400_BAD_REQUEST
default_detail = 'AS is associated with at least one Equipment.'
def __init__(self, msg=None):
if msg:
self.detail = msg
else:
self.detail = self.default_detail
[docs]class AsnErrorV4(Exception):
"""Generic exception for everything related to AS."""
def __init__(self, message):
self.message = message
def __str__(self):
return str(self.message)
[docs]class AsnDoesNotExistException(APIException):
status_code = status.HTTP_404_NOT_FOUND
default_detail = 'AS doesn not exists.'
[docs]class AsnEquipmentNotFoundError(APIException):
status_code = status.HTTP_404_NOT_FOUND
def __init__(self, msg):
self.detail = u'ASN %s do not exist.' % (msg)
[docs]class AsnEquipmentError(APIException):
status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
def __init__(self, msg):
self.detail = msg