Announcement

Collapse
No announcement yet.

Errors not being shown on the UI after upgrade to 7.0.10 from 6.1.0

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Errors not being shown on the UI after upgrade to 7.0.10 from 6.1.0

    Hello,

    I have some validations to some fields in the beforeSave hook and if the validation fails I want the error message to be show to the user in the UI.

    I have the following code in the beforeSave hook function:
    Code:
    if ($entity->isAttributeChanged('stage') && in_array($entity->get('stage'), ['closed lost', 'disqualified']) && empty($entity->get('reasonForLoss'))) {
        throw new BadRequest('Reason for lost should be filled!!', 400);
    }
    This was working fine in ESPO Version 6.1.0 but after I upgraded to 7.0.10, I just get an "Error Occurred" message in the UI and not my custom error message.

    The logs under data/logs shows the errors just like before and even in the browser dev tools everything looks fine.

    Was there any change done to the error handling in ESPO 7? What am I doing wrong?

    item Any ideas?

  • #2
    Try throwing Conflict exception.

    For backend save error handling it's recommended to use save-error-handlers: https://github.com/espocrm/documenta...or-handlers.md

    Comment


    • #3
      The error seems to works for POST API calls but not for PUT APIs.

      I have a beforeSave hook for Task where when a task is being created (a POST API to the backend), if the name is not specified, user gets an error in the UI. This works as expected. But for any updates (a PUT API call to the backend) on an entity the process does not work as expected.

      I haven't gotten time to try out the save-error handlers yet. Will try it out once I get some of the other issues sorted. But seems weird when the system works or some type of API call and not other.

      Comment


      • AgentT
        AgentT commented
        Editing a comment
        Yep. Seems like the problem exists only for PUT APIs. Maybe something is wrong with the routing or something.

        yuri was there any change done to the error handling?

    • #4
      Hey yuri the back-end errors are not being shown in the front-end, like the error message will be shown for a quick second and the panel will be quickly replaced with "Error Occurred". But I have the error in the console saying "Server side error 500: <ERROR MESSAGE FROM BACKEND>".

      This implementation was working fine in ESPO V6, but in V7 its causing problems.

      Comment

      Working...
      X