Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Error handling for User errors #226

Merged
merged 1 commit into from
Nov 28, 2023
Merged

Conversation

raphaelahrens
Copy link
Contributor

Some issues where raised where the users made an error when executing pytm on the shell.

It seems that the issue is that pytm is not returning a custom error but just a Python trace.

This commit add the UIError, which will be handled inside the process function.

UIError is a warpper arround another exception and adds a context description.

This commit only adds UIError for open calls in pytm, since these are obvious pitfalls for users.

Some issues where raised where the users made an error when
executing pytm on the shell.

It seems that the issue is that pytm is not returning a custom error but
just a Python trace.

This commit add the UIError, which will be handled inside the process
function.

UIError is a warpper arround another exception and adds a context
description.

This commit only adds UIError for open calls in pytm, since these are
obvious pitfalls for users.
@raphaelahrens
Copy link
Contributor Author

I was also looking into ValueError which are a common source of errors.
But an ValueError can only be caught in the tm.py file.
So sadly it is not possible to replace these error with more user friendly message, without introducing boilerplate code

def tm_fun():
    web = Server("Web Server")
....
if __name__ == "__main__":
    tm.process(tm_fun)

Or to change the calling convention from

python3 tm.py --report "$file"

to something like

python3 -m pytm tm.py  --report "$file"

Since then you can catch the exceptions while importing tm.py

Either way I think it would help users to better distinguish between bugs and input errors.

@raphaelahrens raphaelahrens marked this pull request as ready for review November 28, 2023 13:07
@izar izar merged commit 4dfa939 into OWASP:master Nov 28, 2023
4 checks passed
@izar
Copy link
Collaborator

izar commented Nov 28, 2023

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants