Skip to content

Refactor code to handle errors more precisely #71

Open
@DavidRomanovizc

Description

@DavidRomanovizc

Example code with try-except block covering the entire code block:

How not to do it

try:
    # some code here
except:
    print("Error occurred")

Example code with more accurate error handling:

How to do it right

# some code here
try:
    result = some_function() # function that we expect might raise an exception
except SomeSpecificError as e:
    # handle specific error
    logging.error(f"Error occurred: {e}")
except Exception as e:
    # handle any other unexpected errors
    logging.error(f"Unexpected error occurred: {e}")

It is necessary to check the entire code and correct where this occurs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority: LowThis issue can probably be picked up by anyone looking to contribute to the project, as an entry fixStatus: BlockedAnother prior issue or need for specific input to make progress. External blockers may also existType: Difficulta long problem and a difficult one

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions