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

кастомизировать и идентифицировать Exception #87

Open
ArtemBalandin81 opened this issue Jul 12, 2024 · 0 comments
Labels
refactoring Refactorings and optimizations

Comments

@ArtemBalandin81
Copy link
Owner

ArtemBalandin81 commented Jul 12, 2024

Why

Местами мы ловим исключения без кастомизации и идентифицикации Exception:

        try:  # if files are attached to another models, they won't be deleted!!!
            await file_service.remove_files(files_ids_set_to_suspension, FILES_DIR)
            await log.ainfo(
                "{}{}{}{}".format(SUSPENSION, suspension_id, SPACE, FILES_UNUSED_IN_FOLDER_REMOVED),
                suspension_id=suspension_id,
                files=files_to_delete,
            )
        except Exception as e:  # todo кастомизировать и идентифицировать Exception
            await log.ainfo(
                "{}{}{}{}".format(
                    SUSPENSION, suspension_id, SPACE, FILES_IDS_INTERSECTION, files_ids_set_to_suspension
                ),
                exception=e,
                suspension_id=suspension_id,
                files=files_to_delete,
                intersection=files_ids_set_to_suspension,
            )
            await suspension_service.remove(suspension_id)
            await log.ainfo("{}{}{}".format(SUSPENSION, suspension_id, DELETED_OK))

How to do

  • Создать, или использовать имеющиеся кастомные классы исключений
  • Избавиться от анонимности исключений
  • Найти в проекте подобные места и рафачить их
  • Воспользоваться подсказками Прочарити

Where

  • src/api/endpoints/suspensions.py
@ArtemBalandin81 ArtemBalandin81 added the refactoring Refactorings and optimizations label Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Refactorings and optimizations
Projects
None yet
Development

No branches or pull requests

1 participant