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

Accessing application error code from the resource #388

Open
sebasjimenez10 opened this issue Aug 26, 2021 · 1 comment
Open

Accessing application error code from the resource #388

sebasjimenez10 opened this issue Aug 26, 2021 · 1 comment

Comments

@sebasjimenez10
Copy link
Contributor

tl;dr

Similar to #368 I found myself needing to extract the application error code from a response with errors.

I was able to get it via the last_result_set attribute on the resource instance. However, this does seem as an undesired way to grab the application error code.

Context

For context, given a response like this one:

{
  "errors": [
    {
      "title": "Name Validation Error",
      "detail": "name - can't be used more than once per family member",
      "code": "1000",
      "source": {
        "pointer": "/data/attributes/name"
      },
      "status": "422"
    }
  ]
}

I would like to extract the application error code (see the "code: 1000" piece) from the resource errors in somewhat a similar way to:

family_member.errors.code
# or
family_member.errors.application_codes
# or
family_member.errors.attrs['codes']

This would allow clients to map application error codes better.

Can I please get some guidance or feedback here!? Thanks in advance! I would love to contribute as well if this is something that makes sense for the future of the project.

@sobakasu
Copy link

this is similar to #195

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

No branches or pull requests

2 participants