Skip to content

Commit 7166fb4

Browse files
committed
refactor: enhance exception classes with descriptive error messages
1 parent 3b7ba08 commit 7166fb4

File tree

1 file changed

+48
-12
lines changed

1 file changed

+48
-12
lines changed

pydoll/exceptions.py

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,82 @@
11
class ConnectionFailed(Exception):
2-
pass
2+
message = "Failed to connect to the browser"
3+
4+
def __str__(self):
5+
return self.message
36

47

58
class InvalidCommand(Exception):
6-
pass
9+
message = "The command provided is invalid"
10+
11+
def __str__(self):
12+
return self.message
713

814

915
class InvalidCallback(Exception):
10-
pass
16+
message = "The callback provided is invalid"
17+
18+
def __str__(self):
19+
return self.message
1120

1221

1322
class NetworkError(Exception):
14-
pass
23+
message = "A network error occurred"
24+
25+
def __str__(self):
26+
return self.message
1527

1628

1729
class InvalidResponse(Exception):
18-
pass
30+
message = "The response received is invalid"
31+
32+
def __str__(self):
33+
return self.message
1934

2035

2136
class ReconnectionFailed(Exception):
22-
pass
37+
message = "Failed to reconnect to the browser"
38+
39+
def __str__(self):
40+
return self.message
2341

2442

2543
class ResendCommandFailed(Exception):
26-
pass
44+
message = "Failed to resend the command"
45+
46+
def __str__(self):
47+
return self.message
2748

2849

2950
class BrowserNotRunning(Exception):
30-
pass
51+
message = "The browser is not running"
52+
53+
def __str__(self):
54+
return self.message
3155

3256

3357
class ElementNotFound(Exception):
34-
pass
58+
message = "The specified element was not found"
59+
60+
def __str__(self):
61+
return self.message
3562

3663

3764
class ClickIntercepted(Exception):
38-
pass
65+
message = "The click was intercepted"
66+
67+
def __str__(self):
68+
return self.message
3969

4070

4171
class ElementNotVisible(Exception):
42-
pass
72+
message = "The element is not visible"
73+
74+
def __str__(self):
75+
return self.message
4376

4477

4578
class ElementNotInteractable(Exception):
46-
pass
79+
message = "The element is not interactable"
80+
81+
def __str__(self):
82+
return self.message

0 commit comments

Comments
 (0)