1+ from .file import File
2+
3+
14class SquareException (BaseException ):
25 """abstract class SquareException"""
36
@@ -11,7 +14,9 @@ def __str__(self):
1114class RequestError (SquareException ):
1215 """raised when a request fails"""
1316
14- def __init__ (self , route : str , status_code : int , code : str ):
17+ def __init__ (
18+ self , route : str , status_code : int , code : str , * args , ** kwargs
19+ ):
1520 self .route = route
1621 self .status = status_code
1722 self .code = code
@@ -102,3 +107,93 @@ class BadMemory(RequestError):
102107 def __init__ (self , * args , ** kwargs ):
103108 super ().__init__ (* args , ** kwargs )
104109 self .message = 'No memory available'
110+
111+
112+ class InvalidConfig (RequestError ):
113+ """
114+ raised when the config file is corrupt or invalid.
115+ """
116+
117+ def __init__ (self , file : File , * args , ** kwargs ):
118+ super ().__init__ (* args , ** kwargs )
119+ self .message = f'{ file .filename } have a invalid config file'
120+
121+
122+ class InvalidDisplayName (InvalidConfig ):
123+ """
124+ raised when the display name in the config file is invalid.
125+ """
126+
127+ def __init__ (self , file : File , * args , ** kwargs ):
128+ super ().__init__ (file = file , * args , ** kwargs )
129+ self .message = 'Invalid display name in config file'
130+
131+
132+ class MissingDisplayName (InvalidConfig ):
133+ """
134+ raised when the display name in the config file is missing.
135+ """
136+
137+ def __init__ (self , * args , ** kwargs ):
138+ super ().__init__ (* args , ** kwargs )
139+ self .message = 'Display name is missing in the config file'
140+
141+
142+ class InvalidMain (InvalidConfig ):
143+ """
144+ raised when the main file in the config file is invalid.
145+ """
146+
147+ def __init__ (self , file : File , * args , ** kwargs ):
148+ super ().__init__ (file = file , * args , ** kwargs )
149+ self .message = 'Invalid main file in config file'
150+
151+
152+ class MissingMainFile (InvalidConfig ):
153+ """
154+ raised when the main file in the config file is missing.
155+ """
156+
157+ def __init__ (self , * args , ** kwargs ):
158+ super ().__init__ (* args , ** kwargs )
159+ self .message = 'Main file is missing in the config file'
160+
161+
162+ class InvalidMemory (InvalidConfig ):
163+ """
164+ raised when the memory value in the config file is invalid.
165+ """
166+
167+ def __init__ (self , file : File , * args , ** kwargs ):
168+ super ().__init__ (file = file , * args , ** kwargs )
169+ self .message = 'Invalid memory value in config file'
170+
171+
172+ class MissingMemory (InvalidConfig ):
173+ """
174+ raised when the memory value in the config file is missing.
175+ """
176+
177+ def __init__ (self , * args , ** kwargs ):
178+ super ().__init__ (* args , ** kwargs )
179+ self .message = 'Memory value is missing in the config file'
180+
181+
182+ class InvalidVersion (InvalidConfig ):
183+ """
184+ raised when the version value in the config file is invalid.
185+ """
186+
187+ def __init__ (self , file : File , * args , ** kwargs ):
188+ super ().__init__ (file = file , * args , ** kwargs )
189+ self .message = 'Invalid version value in config file'
190+
191+
192+ class MissingVersion (InvalidConfig ):
193+ """
194+ raised when the version value in the config file is missing.
195+ """
196+
197+ def __init__ (self , * args , ** kwargs ):
198+ super ().__init__ (* args , ** kwargs )
199+ self .message = 'Version value is missing in the config file'
0 commit comments