AnsweredAssumed Answered

How to display Custom Exception in UI Record/List/subpanel view

Question asked by Aravind Kumar on Sep 27, 2018
Latest reply on Oct 8, 2018 by Francesca Shiekh

Hi all,


I have created a Custom Exceptions using sugarcrm document here but I can't able to display the custom error message for it.

I have created a message for Error code 403. Similar to the following:

class cstmSugarApiExceptionError extends SugarApiException{    
public $httpCode = 403;   
public $errorLabel = 'my_error';   
public $messageLabel = 'EXCEPTION_CSTM_LABEL_KEY';

I can able to see the custom error in developer console of my web browser but I get a general error message.    

`Page does not exist or you do not have permission to access this page.`  but I'm trying to show my custom error message in the UI, Is there any way to do it?


I tried the following:

When checking how sugar handles it I can see in `src/clients/base/views/record/record.js` on initialize 


showNoAccessError is called to show the general message.  In my scenario I'm trying to throw the exception when saving the record, so the "_saveModel" in record.js is called wherein the `error.status === 403` is commonly checked and the message is not used for display error in the UI.

I can change the core to handle the custom error but I'm not happy to do it. So is there any other way to do it?




1. How to show custom exception message in UI?

2. How to write the solution in one place so we can show the error message in List/Record/Create/Subpanel view.?