added useful exception info to ed

This commit is contained in:
Luxferre
2025-12-21 11:36:08 +02:00
parent 4c9195a7cc
commit dbfaaeb4c9
+5 -5
View File
@@ -162,7 +162,7 @@ class Ed:
sep = params[0]
parts = params.split(sep)
if len(parts) < 3:
print("?")
print("Invalid s/old/new syntax")
continue
old, new = parts[1], parts[2]
start = max(1, start)
@@ -176,7 +176,7 @@ class Ed:
elif cmd_char == 'w':
target = params if params else self.filename
if not target:
print("?")
print("No target file to write to")
continue
with open(target, "w") as f:
for line in self.buffer:
@@ -191,10 +191,10 @@ class Ed:
print(self.filename if self.filename else "No current filename")
else:
print("?")
print("Unknown command")
except Exception:
print("?")
except Exception as e:
print(f"Exception occurred: {e}")
def edit(fname):
editor = Ed(fname)