Skip to content

Accessing application error code from the resource #388

Open
@sebasjimenez10

Description

@sebasjimenez10

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions