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

Adds support for instance attribute and custom attributes #11

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Axeltherabbit
Copy link

As I mentioned here #10 I wasn't sure if there was already a way to do this, if there was never mind I guess.

example:

class Http400BadRequest(APIException):
    status_code = status.HTTP_400_BAD_REQUEST
    instance = "test/custom/thingy"
    extensions = {"errors": "custom stuff", "more custom things": "asd"}

Copy link
Owner

@shivanshs9 shivanshs9 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, suggested some small improvements.

if isinstance(data, dict):
data['title'] = problem_title
data['status'] = problem_status
data['type'] = problem_type
if problem_instance:
data['instance'] = problem_instance
data.update(problem_extensions)
Copy link
Owner

Choose a reason for hiding this comment

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

problem_extensions should be dict so please do a type check here

drf_problems/exceptions.py Show resolved Hide resolved
@Axeltherabbit
Copy link
Author

Are the changes fine? Can this be merged?

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