1
- class SpotifyException (Exception ):
1
+ class SpotifyBaseException (Exception ):
2
+ pass
3
+
4
+
5
+ class SpotifyException (SpotifyBaseException ):
2
6
3
7
def __init__ (self , http_status , code , msg , reason = None , headers = None ):
4
8
self .http_status = http_status
@@ -14,3 +18,26 @@ def __init__(self, http_status, code, msg, reason=None, headers=None):
14
18
def __str__ (self ):
15
19
return 'http status: {}, code:{} - {}, reason: {}' .format (
16
20
self .http_status , self .code , self .msg , self .reason )
21
+
22
+
23
+ class SpotifyOauthError (SpotifyBaseException ):
24
+ """ Error during Auth Code or Implicit Grant flow """
25
+
26
+ def __init__ (self , message , error = None , error_description = None , * args , ** kwargs ):
27
+ self .error = error
28
+ self .error_description = error_description
29
+ self .__dict__ .update (kwargs )
30
+ super ().__init__ (message , * args , ** kwargs )
31
+
32
+
33
+ class SpotifyStateError (SpotifyOauthError ):
34
+ """ The state sent and state received were different """
35
+
36
+ def __init__ (self , local_state = None , remote_state = None , message = None ,
37
+ error = None , error_description = None , * args , ** kwargs ):
38
+ if not message :
39
+ message = ("Expected " + local_state + " but received "
40
+ + remote_state )
41
+ super (SpotifyOauthError , self ).__init__ (message , error ,
42
+ error_description , * args ,
43
+ ** kwargs )
0 commit comments