Skip to content

Improove Exception handling #10

@ricco386

Description

@ricco386

Install the library and try to execute dodgy script in the directory where are no Python files. Instead of the stack trace, I would imagine an error message or at least empty dict...

<mock-chroot> sh-4.4# dodgy
Traceback (most recent call last):
  File "/usr/bin/dodgy", line 4, in <module>
    dodgy.run.run()
  File "/usr/lib/python2.7/site-packages/dodgy/run.py", line 56, in run
    warnings = run_checks(os.getcwd())
  File "/usr/lib/python2.7/site-packages/dodgy/run.py", line 44, in run_checks
    for msg_parts in check_file(filepath):
  File "/usr/lib/python2.7/site-packages/dodgy/checks.py", line 72, in check_file
    return check_file_contents(to_check.read())
  File "/usr/lib64/python2.7/codecs.py", line 686, in read
    return self.reader.read(size)
  File "/usr/lib64/python2.7/codecs.py", line 492, in read
    newchars, decodedbytes = self.decode(data, self.errors)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x8b in position 1: invalid start byte

<mock-chroot> sh-4.4# dodgy-3.6 
Traceback (most recent call last):
  File "/usr/bin/dodgy-3.6", line 4, in <module>
    dodgy.run.run()
  File "/usr/lib/python3.6/site-packages/dodgy/run.py", line 56, in run
    warnings = run_checks(os.getcwd())
  File "/usr/lib/python3.6/site-packages/dodgy/run.py", line 44, in run_checks
    for msg_parts in check_file(filepath):
  File "/usr/lib/python3.6/site-packages/dodgy/checks.py", line 72, in check_file
    return check_file_contents(to_check.read())
  File "/usr/lib64/python3.6/codecs.py", line 698, in read
    return self.reader.read(size)
  File "/usr/lib64/python3.6/codecs.py", line 501, in read
    newchars, decodedbytes = self.decode(data, self.errors)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions