|
|
|
|
|
by Karellen
953 days ago
|
|
> So if we want to be really safe then we'll wrap each call with a try/catch: try:
thing.set_name("Doodad")
except Exception as err:
raise Exception(f"failed to set name: {err}") from err
> As we think about each possible error we realize that our original logic would crash the program when we didn't want it to! But while this is safe it's also extremely verbose.How is this safer than the original? If the caller wasn't catching exceptions thrown by this function before, it's not catching exceptions thrown by this function now. What is being gained by catching an exception to do nothing but throw another exception? This feels like a strawman. |
|