Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# -*- coding: utf-8 -*- 

2""" 

3@file 

4@brief An specific exception for Azure 

5""" 

6 

7 

8class AzureException(Exception): 

9 

10 """ 

11 exception raised by @see cl AzureClient 

12 """ 

13 

14 def __init__(self, message, ret): 

15 """ 

16 store more information than a regular exception 

17 

18 @param message error message 

19 @param ret results of the requests 

20 """ 

21 Exception.__init__(self, message) 

22 

23 if ret is not None: 

24 code = ret.status_code 

25 try: 

26 js = ret.json() 

27 except Exception as e: 

28 js = str(e) + "\n" + str(ret) 

29 

30 self.ret = (code, js, ret) 

31 else: 

32 self.ret = (None, None) 

33 

34 def __str__(self): 

35 """ 

36 usual 

37 """ 

38 s = Exception.__str__(self) 

39 f = "STATUS: {0}, JSON: {1}\n{2}\nREQUEST:\n{3}".format( 

40 self.ret[0], self.ret[1], s, self.ret[2]) 

41 return f