11"""Exceptions for the Nextcloud API."""
22
3- from niquests import HTTPError , Response
3+ from niquests import AsyncResponse , HTTPError , Response
44
55
66class NextcloudException (Exception ):
@@ -9,9 +9,15 @@ class NextcloudException(Exception):
99 status_code : int
1010 reason : str
1111 info : str
12- response : Response | None
13-
14- def __init__ (self , status_code : int = 0 , reason : str = "" , info : str = "" , response : Response | None = None ):
12+ response : AsyncResponse | Response | None
13+
14+ def __init__ (
15+ self ,
16+ status_code : int = 0 ,
17+ reason : str = "" ,
18+ info : str = "" ,
19+ response : AsyncResponse | Response | None = None ,
20+ ):
1521 super (BaseException , self ).__init__ ()
1622 self .status_code = status_code
1723 self .reason = reason
@@ -27,25 +33,25 @@ def __str__(self):
2733class NextcloudExceptionNotModified (NextcloudException ):
2834 """The exception indicates that there is no need to retransmit the requested resources."""
2935
30- def __init__ (self , reason = "Not modified" , info : str = "" , response : Response | None = None ):
36+ def __init__ (self , reason = "Not modified" , info : str = "" , response : AsyncResponse | Response | None = None ):
3137 super ().__init__ (304 , reason = reason , info = info , response = response )
3238
3339
3440class NextcloudExceptionNotFound (NextcloudException ):
3541 """The exception that is thrown during operations when the object is not found."""
3642
37- def __init__ (self , reason = "Not found" , info : str = "" , response : Response | None = None ):
43+ def __init__ (self , reason = "Not found" , info : str = "" , response : AsyncResponse | Response | None = None ):
3844 super ().__init__ (404 , reason = reason , info = info , response = response )
3945
4046
4147class NextcloudMissingCapabilities (NextcloudException ):
4248 """The exception that is thrown when required capability for API is missing."""
4349
44- def __init__ (self , reason = "Missing capability" , info : str = "" , response : Response | None = None ):
50+ def __init__ (self , reason = "Missing capability" , info : str = "" , response : AsyncResponse | Response | None = None ):
4551 super ().__init__ (412 , reason = reason , info = info , response = response )
4652
4753
48- def check_error (response : Response , info : str = "" ):
54+ def check_error (response : AsyncResponse | Response , info : str = "" ):
4955 """Checks HTTP code from Nextcloud, and raises exception in case of error.
5056
5157 For the OCS and DAV `code` be code returned by HTTP and not the status from ``ocs_meta``.
0 commit comments