LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  How-to raise a custom Error via brainscript?

    Employee
    Posted 04-20-2016 12:03

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: rene.cravioto

    I need to be able to raise a custom Error via brainscript to speed up troubleshooting.
    Currently, a Log entry is only created if a node fails but I would like to be able to inject additional information to the log and raise an error/exception if certain conditions are met while I am executing brainscript within a node.

    Does anyone know how to do this?

    Thanks!


  • 2.  RE: How-to raise a custom Error via brainscript?

    Employee
    Posted 04-20-2016 14:19

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ryeh

    You can try something like the following:

    if someValue > 10
    {
    	setSuccessReturnCode(-1)
    	logError("Value exceeds 10")
    }


  • 3.  RE: How-to raise a custom Error via brainscript?

    Employee
    Posted 04-20-2016 14:35

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ejones

    Look at the abort() function.

    if state=="Error Condition" then abort("We have an error")


  • 4.  RE: How-to raise a custom Error via brainscript?

    Employee
    Posted 04-20-2016 16:43

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: rene.cravioto

    excellent, thanks! it was missing a "THEN"

    Originally posted by: ryeh
    					

    You can try something like the following:

    if someValue > 10 then
    {
    	setSuccessReturnCode(-1)
    	logError("Value exceeds 10")
    }


  • 5.  RE: How-to raise a custom Error via brainscript?

    Employee
    Posted 04-20-2016 16:47

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: rene.cravioto

    thank you ejones, this is exactly what I was looking for.
    But I must say ryeh's approach is very valuable too. I managed to get the node to display the ugly red X while still ;producing an output on one specific pin.
    This allows you to control the flow of the graph in case of an error (should you want it to continue) while displaying the proper troubleshooting hints.