How to show custom error message without error code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • manosingh
    Member
    • Apr 2019
    • 62

    How to show custom error message without error code

    I use the function " throw new BadRequest('my error message');

    But this one throws error along with the error code "Error:400".

    How i can remove the Error:400 from it or is there any other function to throw custom error without error code.

    Please help me on this , Thanks in advance
  • item
    Active Community Member
    • Mar 2017
    • 1476

    #2
    Hello,
    maybe :
    you return a value : myError=true

    and then on client side :

    Espo.Ui.notify('MyError', 'error', 2000);

    Simple for me
    If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

    Comment

    • manosingh
      Member
      • Apr 2019
      • 62

      #3
      Hi Thanks for the response , but i didnt get you clearly

      In my controller function i try to check a conditional throw error

      public function actionDelete($params, $data, $request) {
      try {

      if($result_number_column['count(*)'] > 0)
      {
      throw new BadRequest('schedule which has delivery form cannot be deleted');
      }

      } catch (Exception $ex) {
      throw new Error("Error while delete a proposal.");
      }
      return parent::actionDelete($params, $data, $request);
      }

      I get an error alert like this please find the attachment. in that alert i need to remove "Error:400"

      Attached Files

      Comment

      Working...