Skip to content

Report errors as JSON #117

@mlms13

Description

@mlms13

One common use case for bs-decode is a webserver that decodes the payload of a request. In this case, it would be desirable to send back a 400 response with a response that includes structured errors that are related to the structure of the request.

Something like:

{
  "first_name": {
    "error": "MissingField",
    "description": "Field \"first_name\" is required but was not present"
  },
  "order_ids": [
    {
      "position": 3,
      "error": "InvalidValue",
      "description": "Expected number but found \"3\""
    }
  ]
}

Not sure what the exact structure should be, but it should be something predictable and easy to describe, so that your webserver can document the errors it will return and clients can theoretically do something useful with that data structure.

We already have examples of converting the structured ParseError type to a string in a way that preserves some of the nesting structure, so I think this should be pretty doable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions