@@ -8,12 +8,15 @@ class NextcloudException(Exception):
88
99 status_code : int
1010 reason : str
11+ info : str
12+ response : Response | None
1113
12- def __init__ (self , status_code : int = 0 , reason : str = "" , info : str = "" ):
14+ def __init__ (self , status_code : int = 0 , reason : str = "" , info : str = "" , response : Response | None = None ):
1315 super (BaseException , self ).__init__ ()
1416 self .status_code = status_code
1517 self .reason = reason
1618 self .info = info
19+ self .response = response
1720
1821 def __str__ (self ):
1922 reason = f" { self .reason } " if self .reason else ""
@@ -24,22 +27,22 @@ def __str__(self):
2427class NextcloudExceptionNotModified (NextcloudException ):
2528 """The exception indicates that there is no need to retransmit the requested resources."""
2629
27- def __init__ (self , reason = "Not modified" , info : str = "" ):
28- super ().__init__ (304 , reason = reason , info = info )
30+ def __init__ (self , reason = "Not modified" , info : str = "" , response : Response | None = None ):
31+ super ().__init__ (304 , reason = reason , info = info , response = response )
2932
3033
3134class NextcloudExceptionNotFound (NextcloudException ):
3235 """The exception that is thrown during operations when the object is not found."""
3336
34- def __init__ (self , reason = "Not found" , info : str = "" ):
35- super ().__init__ (404 , reason = reason , info = info )
37+ def __init__ (self , reason = "Not found" , info : str = "" , response : Response | None = None ):
38+ super ().__init__ (404 , reason = reason , info = info , response = response )
3639
3740
3841class NextcloudMissingCapabilities (NextcloudException ):
3942 """The exception that is thrown when required capability for API is missing."""
4043
41- def __init__ (self , reason = "Missing capability" , info : str = "" ):
42- super ().__init__ (412 , reason = reason , info = info )
44+ def __init__ (self , reason = "Missing capability" , info : str = "" , response : Response | None = None ):
45+ super ().__init__ (412 , reason = reason , info = info , response = response )
4346
4447
4548def check_error (response : Response , info : str = "" ):
@@ -59,12 +62,12 @@ def check_error(response: Response, info: str = ""):
5962 phrase = "Not found"
6063 else :
6164 phrase = "Unknown error"
62- raise NextcloudException (status_code , reason = phrase , info = info )
65+ raise NextcloudException (status_code , reason = phrase , info = info , response = response )
6366
6467 try :
6568 response .raise_for_status ()
6669 except HTTPError as e :
67- raise NextcloudException (status_code , reason = response .reason , info = info ) from e
70+ raise NextcloudException (status_code , reason = response .reason , info = info , response = response ) from e
6871
6972
7073class ModelFetchError (Exception ):
0 commit comments