Open Jlrine2 opened 3 years ago
I think the idea is that, applying the self.type
function to the user's input data could result in any exception. We can't know the possible exceptions beforehand. Possibly this could be tightened to Exception
, though.
Tightening it to Exception
would still make me wary, I'd lean toward wanting this to be exception neutral, the self.type
function is user code, if it throws the exception should be sent back to the user for handling. If that is the only place an exception is expected, I would lean towards not catching it.
Since it is catching a BaseException
over a large block of code, I worry that it will catch unexpected errors and make them a bit harder to find.
regardless of what is caught, re raising it would be preffered over exit(1)
Yes, if I were doing anything with the error (like parsing the rest of the arguments), then maybe this would be justified but since I just exit(1)
I see no reason to keep the try/except
at all. Feel free to put in a PR, otherwise I'll remove it eventually myself.
https://github.com/TMiguelT/ArgparsePrompt/blob/aeff7263e2e3aa0a5f25610987808cec6aa322f8/argparse_prompt.py#L94
This library catches a
BaseException
inPrompt.__call__()
this should catch only the specific exceptions that are expected, and raise instead ofexit(1)
so that I can catch errors and handle them