# Show error text in orange error popup when error on route

**URL:** <https://community.forestadmin.com/t/show-error-text-in-orange-error-popup-when-error-on-route/303>\
**Category:** Help me!\
**Created:** [May 25, 2020, 6:59pm UTC](https://community.forestadmin.com/t/show-error-text-in-orange-error-popup-when-error-on-route/303 "2020-05-25T18:59:28Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![XavierColombel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/xaviercolombel/32/106_2.png) [@XavierColombel](https://community.forestadmin.com/u/XavierColombel)\
**Post date:** [May 25, 2020, 6:59pm UTC](https://community.forestadmin.com/t/show-error-text-in-orange-error-popup-when-error-on-route/303/1 "2020-05-25T18:59:28Z")

</div>

## Expected behavior

I want to show the error text I throw in the orange error popup. I talk about extended routes.

## Actual behavior

When I’ve got an error in a collection (Users here), Forest produce this error text : `Users deletion failed: unexpected error.` instead the text error I pass in the `next`.

For instance, in your documentation, it’s possible to throw a specific error text, but it never appears in the orange error popup:

```javascript
router.delete('/companies/:recordId', permissionMiddlewareCreator.delete(), (request, response, next) => {
  if (request.params.recordId === 82) {
    next(new Error('This record is protected, you cannot remove it.'));
    return;
  }

  const recordRemover = new RecordRemover(companies);
  recordRemover.remove(request.params.recordId)
    .then(() => response.status(204).send())
    .catch(next);
});

```

---

<div class="post-metadata">

**Author:** ![arnaud](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/arnaud/32/32_2.png) [@arnaud](https://community.forestadmin.com/u/arnaud)\
**Post date:** [May 26, 2020, 6:41am UTC](https://community.forestadmin.com/t/show-error-text-in-orange-error-popup-when-error-on-route/303/2 "2020-05-26T06:41:32Z")

</div>

Hi @XavierColombel,

I think the documentation is not up-to-date.  
I’ll report this.

The following implementation should work as expected:

```javascript
router.delete('/companies/:recordId', permissionMiddlewareCreator.delete(), (request, response, next) => {
  if (request.params.recordId === 82) {
    response.status(403).send('This record is protected, you cannot remove it.');
    return;
  }

  const recordRemover = new RecordRemover(companies);
  recordRemover.remove(request.params.recordId)
    .then(() => response.status(204).send())
    .catch(next);
});

```

---

<div class="post-metadata">

**Author:** ![XavierColombel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/xaviercolombel/32/106_2.png) [@XavierColombel](https://community.forestadmin.com/u/XavierColombel)\
**Post date:** [May 26, 2020, 1:49pm UTC](https://community.forestadmin.com/t/show-error-text-in-orange-error-popup-when-error-on-route/303/3 "2020-05-26T13:49:39Z")

</div>

No, it doesn’t work. I mean, you can’t specify a text for the error.

For instance, if you have this route:

```javascript
router.delete(
  "/users",
  permissionMiddlewareCreator.delete(),
  (request, response, next) => {
    return response.status(400).send("this is a specific error!");
  },
);

```

You’ll have the default error message:

`User deletion failed: unexpected error.`

---

<div class="post-metadata">

**Author:** ![Sliman\_Medini](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/sliman_medini/32/19_2.png) [@Sliman\_Medini](https://community.forestadmin.com/u/Sliman_Medini)\
**Post date:** [May 26, 2020, 2:21pm UTC](https://community.forestadmin.com/t/show-error-text-in-orange-error-popup-when-error-on-route/303/4 "2020-05-26T14:21:06Z")

</div>

Hi Xavier,

I’ve just redone this test-case: it displays well the message error.

This minimal example:

 ![Screenshot 2020-05-26 at 16.13.32](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/1X/720ffdf7e5905547fcef6a1b82aaa688e73dc7bb.png)

Produce this error message:

 ![Screenshot 2020-05-26 at 16.09.48](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/1X/73023a36ae3dc0f4eebd24e139b9fe11c831a898.png)

And output hello in my server log.  
Can you have a try with this minimal hack?  
(I ask myself if maybe you didn’t pass the permission middleware?)

Regards

---

<div class="post-metadata">

**Author:** ![XavierColombel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/xaviercolombel/32/106_2.png) [@XavierColombel](https://community.forestadmin.com/u/XavierColombel)\
**Post date:** [May 26, 2020, 5:29pm UTC](https://community.forestadmin.com/t/show-error-text-in-orange-error-popup-when-error-on-route/303/5 "2020-05-26T17:29:06Z")

</div>

@Sliman_Medini your example is working beacause you use the route `router.delete("/user/:recordId"...`, but try with the route `router.delete("/user", permissionMiddlewareCreator.delete()` without the `recordId` in the route.

---

<div class="post-metadata">

**Author:** ![Sliman\_Medini](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/sliman_medini/32/19_2.png) [@Sliman\_Medini](https://community.forestadmin.com/u/Sliman_Medini)\
**Post date:** [May 27, 2020, 7:29am UTC](https://community.forestadmin.com/t/show-error-text-in-orange-error-popup-when-error-on-route/303/6 "2020-05-27T07:29:29Z")

</div>

Hi Xavier,

You are right, I reproduce your problem on a bulk route ("/user")

This minimal example:

 ![Screenshot 2020-05-27 at 09.26.12](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/1X/992d0843044d3b3b0219e483c989d5439c04da8b.png)

Produce this error message:

 ![Screenshot 2020-05-27 at 09.27.28](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/1X/ebb43fa350a817e76424c8ea7c425aaa8d51f051.png)

Instead of displaying “big error here”  
I am creating a bug entry to handle this.

Regards

---

<div class="post-metadata">

**Author:** ![XavierColombel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/xaviercolombel/32/106_2.png) [@XavierColombel](https://community.forestadmin.com/u/XavierColombel)\
**Post date:** [May 27, 2020, 8:44am UTC](https://community.forestadmin.com/t/show-error-text-in-orange-error-popup-when-error-on-route/303/7 "2020-05-27T08:44:04Z")

</div>

Thank you @Sliman_Medini

---

<div class="post-metadata">

**Author:** ![arnaud](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/arnaud/32/32_2.png) [@arnaud](https://community.forestadmin.com/u/arnaud)\
**Post date:** [June 1, 2020, 7:09am UTC](https://community.forestadmin.com/t/show-error-text-in-orange-error-popup-when-error-on-route/303/9 "2020-06-01T07:09:15Z")

</div>

Hi @XavierColombel,

The patch for batch delete is currently under review and should be released this week.

---

<div class="post-metadata">

**Author:** ![XavierColombel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/xaviercolombel/32/106_2.png) [@XavierColombel](https://community.forestadmin.com/u/XavierColombel)\
**Post date:** [June 1, 2020, 10:15am UTC](https://community.forestadmin.com/t/show-error-text-in-orange-error-popup-when-error-on-route/303/10 "2020-06-01T10:15:21Z")

</div>

Wow nice! Thanks @arnaud. Can’t wait. 😃

---

<div class="post-metadata">

**Author:** ![arnaud](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/arnaud/32/32_2.png) [@arnaud](https://community.forestadmin.com/u/arnaud)\
**Post date:** [June 2, 2020, 9:49am UTC](https://community.forestadmin.com/t/show-error-text-in-orange-error-popup-when-error-on-route/303/11 "2020-06-02T09:49:51Z")

</div>

The patch is now live.  
You just have to refresh you browser page to benefit from it.

---

<div class="post-metadata">

**Author:** ![XavierColombel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/xaviercolombel/32/106_2.png) [@XavierColombel](https://community.forestadmin.com/u/XavierColombel)\
**Post date:** [June 2, 2020, 10:00am UTC](https://community.forestadmin.com/t/show-error-text-in-orange-error-popup-when-error-on-route/303/12 "2020-06-02T10:00:53Z")

</div>

Thanks @arnaud ! I’ll test later. 👍
