# ROM-HTTP: Error handling

**URL:** <https://discourse.rom-rb.org/t/rom-http-error-handling/444>\
**Category:** Issues\
**Created:** [March 13, 2021, 9:51am UTC](https://discourse.rom-rb.org/t/rom-http-error-handling/444 "2021-03-13T09:51:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![drqCode](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.rom-rb.org/drqcode/32/160_2.png) [@drqCode](https://discourse.rom-rb.org/u/drqCode)\
**Post date:** [March 13, 2021, 9:51am UTC](https://discourse.rom-rb.org/t/rom-http-error-handling/444/1 "2021-03-13T09:51:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![solnic](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.rom-rb.org/solnic/32/279_2.png) [@solnic](https://discourse.rom-rb.org/u/solnic)\
**Post date:** [March 15, 2021, 1:35pm UTC](https://discourse.rom-rb.org/t/rom-http-error-handling/444/2 "2021-03-15T13:35:19Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![drqCode](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.rom-rb.org/drqcode/32/160_2.png) [@drqCode](https://discourse.rom-rb.org/u/drqCode)\
**Post date:** [March 20, 2021, 10:32am UTC](https://discourse.rom-rb.org/t/rom-http-error-handling/444/3 "2021-03-20T10:32:51Z")

</div>

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.
