Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.10/site-packages/msal/exceptions.py: 67%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

9 statements  

1#------------------------------------------------------------------------------ 

2# 

3# Copyright (c) Microsoft Corporation. 

4# All rights reserved. 

5# 

6# This code is licensed under the MIT License. 

7# 

8# Permission is hereby granted, free of charge, to any person obtaining a copy 

9# of this software and associated documentation files(the "Software"), to deal 

10# in the Software without restriction, including without limitation the rights 

11# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell 

12# copies of the Software, and to permit persons to whom the Software is 

13# furnished to do so, subject to the following conditions : 

14# 

15# The above copyright notice and this permission notice shall be included in 

16# all copies or substantial portions of the Software. 

17# 

18# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 

19# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 

20# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE 

21# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 

22# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 

23# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 

24# THE SOFTWARE. 

25# 

26#------------------------------------------------------------------------------ 

27 

28class MsalError(Exception): 

29 # Define the template in Unicode to accommodate possible Unicode variables 

30 msg = u'An unspecified error' # Keeping for backward compatibility 

31 

32 

33class MsalServiceError(MsalError): 

34 msg = u"{error}: {error_description}" # Keeping for backward compatibility 

35 def __init__( 

36 self, 

37 *args, 

38 error: str, error_description: str, # Historically required, keeping them for now 

39 # 1. We can't simply remove them, or else it will be a breaking change 

40 # 2. We may change them to optional without breaking anyone. However, 

41 # such a change will be a one-way change, because once being optional, 

42 # we will never be able to change them (back) to be required. 

43 # 3. Since they were required and already exist anyway, 

44 # now we just keep them required "for now", 

45 # just in case that we would use them again. 

46 # There is no plan to do #1; and we keep option #2 open; we go with #3. 

47 **kwargs, 

48 ): 

49 super().__init__(*args, **kwargs) 

50 self._error = error 

51 self._error_description = error_description 

52