1#-------------------------------------------------------------------------
2# Copyright (c) Microsoft Corporation. All rights reserved.
3# Licensed under the MIT License. See License.txt in the project root for
4# license information.
5#--------------------------------------------------------------------------
6from ._version import VERSION as _VERSION
7
8__author__ = 'Microsoft Corp. <azpysdkhelp@microsoft.com>'
9__version__ = _VERSION
10
11
12class AzureException(Exception):
13    pass
14
15
16class AzureHttpError(AzureException):
17    def __init__(self, message, status_code):
18        super(AzureHttpError, self).__init__(message)
19        self.status_code = status_code
20
21    def __new__(cls, message, status_code, *args, **kwargs):
22        if cls is AzureHttpError:
23            if status_code == 404:
24                cls = AzureMissingResourceHttpError
25            elif status_code == 409:
26                cls = AzureConflictHttpError
27        return AzureException.__new__(cls, message, status_code, *args, **kwargs)
28
29
30class AzureConflictHttpError(AzureHttpError):
31    def __init__(self, message, status_code):
32        super(AzureConflictHttpError, self).__init__(message, status_code)
33
34
35class AzureMissingResourceHttpError(AzureHttpError):
36    def __init__(self, message, status_code):
37        super(AzureMissingResourceHttpError, self).__init__(message, status_code)
38