ssossossosso

Forums

Covering OroCRM topics, including community updates and company announcements.  Subscribe

This topic contains 7 replies, has 3 voices, and was last updated by  zhex900 3 months, 2 weeks ago.

  • Creator
    Topic
  • #35705

    zhex900
    Participant

    Hi,
    How do I create a customer error message? I want it to stop the application and display the error message in the flash message.

    Jake He

Viewing 7 replies - 1 through 7 (of 7 total)
  • Author
    Replies
  • #35743

    mmiasnikov
    Oro Core

    Hi, Jake!

    Actually, it depends on where do you want to create an error message. You have following options, for example:

    1) You, of course, always have a regular Symfony-based ability to throw flash messages from Session. In controllers, particularly, you can use addFlash() method for this (please, see the Symfony’s “Controller” documentation article)

    2) In Oro Workflows (and processes) you can use “@flash_message” action:

    For detailed examples, please, look for “@flash_message” usages in workflow definitions in Oro bundles.

    Regards!

    #35748

    zhex900
    Participant

    Hi,

    Thank you for your reply.

    I want to throw an error message in a custom class I had. This is what I done.
    1) Inject session into my class
    2) $this->session->getFlashBag()->add(‘error’, ‘Calendar does not exist.’);

    However this error message is not displayed.

    Jake He

    #35749

    zhex900
    Participant

    What I want is to throw an exception like throw new \Exception( 'Calendar does not exist.');
    I want this exception message to be displayed in the flash message. So replacing Error: Unexpected content format with ‘Calendar does not exist.’

    Screen_Shot_2017_08_01_at_4_58_46_pm

    #35751

    Yurii Muratov
    Oro Core

    Hi, @zhex900. Very strange that you does not see your message from the $this->session->getFlashBag()->add(‘error’, ‘Calendar does not exist.’);. I gust tested your case and all works for me.

    Please see, maybe you have some JS error.

    About the message from the exception. As for me it is not very good idea to send error messages as flash message because user should have translated message that will describe what was going wrong.

    #35752

    zhex900
    Participant

    Error: Unexpected content format flash message displayed first. After I go another page like contacts. Calendar does not exist flash message comes up.

    I want to stop the app and display an error message. Like validation.

    #35799

    zhex900
    Participant

    Hi,

    I know what the problem is. The session service I injected is null. But how do I fix it?

    #35800

    zhex900
    Participant

    I found a work around. I throw an exception and catch it at the class that calls it.

Viewing 7 replies - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.