revivetube/helper.py

11 lines
333 B
Python

def read_file(path):
assert isinstance(path, str), "Path must be a string"
try:
with open(path, 'r', encoding='utf-8') as file:
content = file.read()
return content
except FileNotFoundError:
return "Error: File not found."
except Exception as e:
return f"Error: {str(e)}"