ROM-HTTP: Error handling

Hi! I know there is no error schema support or anything related to API errors, but how to approach errors with ROM-HTTP? For example when creating a resource:

POST /users with some attributes, resulting a 400 Bad request with following body:

{
  "error": {
    "invalid_parameters": [
      {
        "name": "email",
        "detail": "missing"
      }
    ]
  }
}

Currently, I handle 400 responses in a custom ResponseHandler where I wrap the body in a custom raised error which is rescued on a higher level.

hey there, what you did is something I’d do too. I don’t see any reason why that’s not a good idea. Have you faced any problems with it so far?

No issue so far. It is perfectly correct now, but I think there could be some room for an improvement. Now, there are 2 places to check on a specific endpoint definition, instead of one. I mean, a signature of an endpoint also includes the errors it can returns, so it would make more sense to describe this signature in a single place (on relation). If this goes well with rom paradigm, I think it would be a nice feature to have in the future, or at least worth taking it into consideration.

EDIT: This applies to domain errors, like ‘pay request fails due to insufficient funds’. For, other types of errors which are related to the protocol, they can go on a response handler.