Skip to content

Improve Exception Output for run with Missing Handler #70

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

Merged

Conversation

jackcasey-visier
Copy link
Contributor

@jackcasey-visier jackcasey-visier commented Mar 2, 2022

Summary

This change improves the error handling when running awslambdaric without a handler. Currently, the exception thrown is fairly non-specific:

python -m awslambdaric

Traceback (most recent call last):
  File "python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "awslambdaric/__main__.py", line 20, in <module>
    main(sys.argv)
  File "awslambdaric/__main__.py", line 13, in main
    handler = args[1]
IndexError: list index out of range

The changes make the output a bit more human friendly 😄 :

python -m awslambdaric

Traceback (most recent call last):
  File "python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "awslambdaric/__main__.py", line 25, in <module>
    main(sys.argv)
  File "awslambdaric/__main__.py", line 17, in main
    raise ValueError("Handler not set")
ValueError: Handler not set

Even with the changes in place the module exists with an unhandled exception in the same way. We may want to wrap this to provide a more clean exit 😅

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link
Contributor

@zsombor-balogh zsombor-balogh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contributing!

@jackcasey-visier
Copy link
Contributor Author

jackcasey-visier commented May 4, 2022

@zsombor-balogh My pleasure!

@jackcasey-visier
Copy link
Contributor Author

@zsombor-balogh @carlzogh Friendly poke :)

Just curious, is there anything I can do to help move this forward? Is there testing that needs to be accomplished?

Thanks!

@zsombor-balogh zsombor-balogh merged commit 020fa7a into aws:main May 25, 2022
@zsombor-balogh
Copy link
Contributor

@zsombor-balogh @carlzogh Friendly poke :)

Just curious, is there anything I can do to help move this forward? Is there testing that needs to be accomplished?

Thanks!

Apologies for the delay, merged it now!

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.

3 participants