Files
doczyai-pipelines/archive/Doczy.AI_Automation/utils/CustomException.py
T

53 lines
1.5 KiB
Python
Raw Normal View History

2024-08-21 19:26:08 +05:30
from selenium.common import TimeoutException
class CustomError(Exception):
"""Base class for custom exceptions"""
2024-09-30 12:21:29 +01:00
2024-08-21 19:26:08 +05:30
def __init__(self, message):
super().__init__(message)
self.message = message
class InvalidInputError(CustomError):
"""Exception raised for invalid inputs"""
2024-09-30 12:21:29 +01:00
2024-08-21 19:26:08 +05:30
def __init__(self, value):
super().__init__(f"Invalid input: {value}")
self.value = value
class DatabaseConnectionError(CustomError):
"""Exception raised for database connection errors"""
2024-09-30 12:21:29 +01:00
2024-08-21 19:26:08 +05:30
def __init__(self, db_url):
super().__init__(f"Database connection failed: {db_url}")
self.db_url = db_url
class NoYamlFile(FileNotFoundError):
def __init__(self, yaml_file_path, yaml_file_name):
2024-09-30 12:21:29 +01:00
super().__init__(
f"Please create YAML file at location={yaml_file_path} with filename={yaml_file_name}"
)
2024-08-21 19:26:08 +05:30
self.yaml_file_path = yaml_file_path
self.yaml_file_name = yaml_file_name
class NoElementFound(Exception):
def __init__(self, xpath, timeout):
2024-09-30 12:21:29 +01:00
super().__init__(
f'Element with "{xpath}" XPATH is not located in {timeout} second. Try re-run the testcase'
)
2024-08-21 19:26:08 +05:30
self.xpath = xpath
self.timeout = timeout
2024-09-30 12:21:29 +01:00
2024-08-21 19:26:08 +05:30
class TitleNotFound(Exception):
def __init__(self, title, timeout):
2024-09-30 12:21:29 +01:00
super().__init__(
f'Web Page with "{title}" title is not loaded in {timeout} second.'
)
2024-08-21 19:26:08 +05:30
self.title = title
2024-09-30 12:21:29 +01:00
self.timeout = timeout