
from openprovider.exceptions import *

MAPPING = {
    307: BadRequest,   # Invalid domain extension
    501: BadRequest,   # Domain name too short
}


def from_code(code):
    """
    Return the specific exception class for the given code, or OpenproviderError
    if no specific exception class is available.
    """
    if code in MAPPING:
        return MAPPING[code]
    else:
        return OpenproviderError


from openprovider.exceptions import *

MAPPING = {
    307: BadRequest,           # Invalid domain extension
    501: BadRequest,           # Domain name too short
    4005: ServiceUnavailable,  # Temprorarily unavailable due to maintenance
}


def from_code(code):
    """
    Return the specific exception class for the given code, or OpenproviderError
    if no specific exception class is available.
    """
    if code in MAPPING:
        return MAPPING[code]
    else:
        return OpenproviderError

Add maintenance response to exception map
Add maintenance response to exception map

  
  from openprovider.exceptions import *
  
  MAPPING = {
-     307: BadRequest,   # Invalid domain extension
+     307: BadRequest,           # Invalid domain extension
-     501: BadRequest,   # Domain name too short
+     501: BadRequest,           # Domain name too short
+     4005: ServiceUnavailable,  # Temprorarily unavailable due to maintenance
  }
  
  
  def from_code(code):
      """
      Return the specific exception class for the given code, or OpenproviderError
      if no specific exception class is available.
      """
      if code in MAPPING:
          return MAPPING[code]
      else:
          return OpenproviderError
  
Add maintenance response to exception map
## Code Before:

from openprovider.exceptions import *

MAPPING = {
    307: BadRequest,   # Invalid domain extension
    501: BadRequest,   # Domain name too short
}


def from_code(code):
    """
    Return the specific exception class for the given code, or OpenproviderError
    if no specific exception class is available.
    """
    if code in MAPPING:
        return MAPPING[code]
    else:
        return OpenproviderError

## Instruction:
Add maintenance response to exception map
## Code After:

from openprovider.exceptions import *

MAPPING = {
    307: BadRequest,           # Invalid domain extension
    501: BadRequest,           # Domain name too short
    4005: ServiceUnavailable,  # Temprorarily unavailable due to maintenance
}


def from_code(code):
    """
    Return the specific exception class for the given code, or OpenproviderError
    if no specific exception class is available.
    """
    if code in MAPPING:
        return MAPPING[code]
    else:
        return OpenproviderError
