blob: 24145128bf410a02fffc629c9c697208ee99315a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
"""Module for errors thrown from ui_pages."""
from typing import List, Optional
from xml.dom import minidom
from blueberry.utils.ui_pages import ui_node
class Error(Exception):
pass
class ContextError(Error):
"""Context related error."""
def __init__(self, ctx, msg):
new_msg = f'{ctx.ad}: {msg}'
super().__init__(new_msg)
class UIError(Error):
"""UI page related error."""
pass
class UnknownPageError(Error):
"""UI page error for unknown XML content.
Attributes:
ui_xml: Parsed XML object.
clickable_nodes: List of UINode with attribute `clickable="true"`
enabled_nodes: List of UINode with attribute `enabled="true"`
all_nodes: List of all UINode
"""
def __init__(self,
ui_xml: minidom.Document,
clickable_nodes: Optional[List[ui_node.UINode]] = None,
enabled_nodes: Optional[List[ui_node.UINode]] = None,
all_nodes: Optional[List[ui_node.UINode]] = None):
new_msg = f'Unknown ui_xml:\n{ui_xml.toxml()}\n'
self.ui_xml = ui_xml
self.enabled_nodes = enabled_nodes
self.clickable_nodes = clickable_nodes
self.all_nodes = all_nodes
super().__init__(new_msg)
|