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] Added error identifiers #38

Merged
merged 2 commits into from
Sep 3, 2024
Merged

Conversation

samar-hassan
Copy link
Collaborator

Added a feature to identify which instances or resources produce an error.

@@ -76,6 +80,7 @@ def __init__(self, Model, *args, delete_related=False, **kwargs):
self.attribute_data = []
self.errors = []
self.delete_related = delete_related
self.error_identifiers = error_identifiers
Copy link
Member

Choose a reason for hiding this comment

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

self.errors = ErrorLog(self)

@@ -112,6 +117,9 @@ def validate_instances(self, instances, validate_unique=True, fields=None):
validate_unique=validate_unique, exclude=exclude
)
except ValidationError as e:
Copy link
Member

Choose a reason for hiding this comment

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

self.errors.add_error(e, instance)

@@ -75,7 +75,18 @@ def querycounter(*labels, print_queries=False):
print(" ", q)


def validate_resources(resources):
def set_error_identifiers(error, record, error_identifiers):
Copy link
Member

Choose a reason for hiding this comment

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

class ErrorLog(list):
    def __init__(self, context):
        self.context = context

    def add_error(self, exception, instance):
        self.append(self.compute_error_identifier(exception, instance)

    def register_error_type(self, cls):
        # some way of registering a error indentifier computation function

@specialunderwear specialunderwear merged commit 6119c85 into master Sep 3, 2024
5 checks passed
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.

2 participants