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

feat: add exceptions #15

Closed
wants to merge 6 commits into from
Closed

feat: add exceptions #15

wants to merge 6 commits into from

Conversation

psankhe28
Copy link
Collaborator

@psankhe28 psankhe28 commented Aug 6, 2024

Description

  • Fixes #(issue number)

Fixes #14

Checklist

  • My code follows the contributing guidelines
    of this project, including, in particular, with regard to any style guidelines
  • The title of my PR complies with the
    Conventional Commits specification; in particular, it clearly
    indicates that a change is a breaking change
  • I acknowledge that all my commits will be squashed into a single commit,
    using the PR title as the commit message
  • I have performed a self-review of my own code
  • I have commented my code in hard-to-understand areas
  • I have updated the user-facing documentation to describe any new or
    changed behavior
  • I have added type annotations for all function/class/method interfaces
    or updated existing ones (only for Python, TypeScript, etc.)
  • I have provided appropriate documentation
    (Google-style Python docstrings) for all
    packages/modules/functions/classes/methods or updated existing ones
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature
    works
  • New and existing unit tests pass locally with my changes
  • I have not reduced the existing code coverage

Comments

Summary by Sourcery

Add a new module for handling exceptions in the Tus Storage Handler, including custom messages and status codes for various error types.

New Features:

  • Introduce custom exception handling for the Tus Storage Handler.

Signed-off-by: Prati28 <[email protected]>
Copy link
Contributor

sourcery-ai bot commented Aug 6, 2024

Reviewer's Guide by Sourcery

This pull request introduces custom exception handling to the Tus Storage Handler. A new file exceptions.py was added, which defines a GenericException class and a dictionary to map various exceptions to specific error messages and codes. This enhancement aims to provide more informative error handling within the Tus Storage Handler.

File-Level Changes

Files Changes
tus_storagehandler/exceptions.py Introduced custom exception handling for the Tus Storage Handler, including specific error messages and codes for different types of exceptions.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @psankhe28 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding unit tests to verify the behavior of these new exceptions.
  • It would be helpful to include docstrings or comments explaining when and how these exceptions are used in the codebase.
Here's what I looked at during the review
  • 🟡 General issues: 3 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

tus_storagehandler/exceptions.py Outdated Show resolved Hide resolved
tus_storagehandler/exceptions.py Outdated Show resolved Hide resolved
tus_storagehandler/exceptions.py Outdated Show resolved Hide resolved
@psankhe28 psankhe28 marked this pull request as draft August 6, 2024 19:06
Copy link

codecov bot commented Aug 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (0516517) to head (86fcc9c).

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #15   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines            8         8           
=========================================
  Hits             8         8           
Flag Coverage Δ
test_integration 100.00% <ø> (ø)
test_unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

psankhe28 and others added 5 commits August 7, 2024 10:19
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Signed-off-by: Prati28 <[email protected]>
Signed-off-by: Prati28 <[email protected]>
Signed-off-by: Prati28 <[email protected]>
Signed-off-by: Prati28 <[email protected]>
@psankhe28 psankhe28 requested a review from uniqueg August 7, 2024 05:08
@psankhe28 psankhe28 marked this pull request as ready for review August 7, 2024 05:08
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @psankhe28 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding unit tests and documentation for the new exception handling to ensure proper functionality and usage.
  • The GenericException and catch-all Exception seem redundant. Consider using more specific exception types instead.
  • Please provide more context about issue feat: exceptions in case of errors #14 in the PR description to clarify the problem this change is addressing.
Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

from werkzeug.exceptions import BadRequest, InternalServerError, NotFound


class GenericException(Exception):
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Consider removing or enhancing GenericException

The GenericException class doesn't add any functionality beyond the built-in Exception. Consider removing it or adding specific behavior if it's needed.

class TusStorageHandlerException(Exception):
    """Base exception for the Tus Storage Handler."""
    def __init__(self, message="An error occurred in the Tus Storage Handler"):
        self.message = message
        super().__init__(self.message)

pass


exceptions = {
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Revise error messages for clarity and professionalism

Some error messages, like the one for BadRequest, could be more professional and informative. Consider revising these to provide more specific and actionable information.

exceptions = {
    Exception: {
        "message": "An unexpected error occurred. Please try again or contact support.",
    },
    BadRequest: {
        "message": "Invalid request. Please check your input and try again.",
    },
    NotFound: {
        "message": "The requested resource could not be found.",
    },
    Unauthorized: {
        "message": "Authentication required. Please log in and try again.",
    },
}

Copy link
Member

@uniqueg uniqueg left a comment

Choose a reason for hiding this comment

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

Please include exceptions in the FOCA setup PR (#13) and close this PR

@psankhe28 psankhe28 closed this Aug 8, 2024
@psankhe28 psankhe28 deleted the exceptions branch September 5, 2024 07:59
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.

feat: exceptions in case of errors
2 participants