File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -326,7 +326,10 @@ def read_file(file_path):
326
326
data = file.read()
327
327
return data
328
328
except FileNotFoundError:
329
- raise FileNotFoundError(f"Oops! I couldn't find the file located at: {file_path}. Please check to see if it exists.")
329
+ raise FileNotFoundError(
330
+ f"Oops! I couldn't find the file located at: {file_path}. "
331
+ "Please check to see if it exists."
332
+ ) # no "from" statement implicitly chains the prior error
330
333
331
334
332
335
file_data = read_file("nonexistent_file.txt")
@@ -345,7 +348,10 @@ def read_file(file_path):
345
348
data = file.read()
346
349
return data
347
350
except FileNotFoundError:
348
- raise FileNotFoundError(f"Oops! I couldn't find the file located at: {file_path}. Please check to see if it exists.") from None
351
+ raise FileNotFoundError(
352
+ f"Oops! I couldn't find the file located at: {file_path}. "
353
+ "Please check to see if it exists."
354
+ ) from None # explicitly break the exception chain
349
355
350
356
351
357
file_data = read_file("nonexistent_file.txt")
You can’t perform that action at this time.
0 commit comments