Undocumented Exception-Handling Logic Hooks

SugarCRM features lots of documented logic hooks, but this is the first time I’ve encountered these error/exception handling ones. I just happened to see them in some code I was browsing.

These hooks are apparently undocumented, and I can only think of a single use case for performing actions based on receiving a PHP Exception, and that would be to tie-in to a third-party logging or monitoring tool.

Still, cool to see in the system.

The code block is in include/MVC/Controller/SugarController.php. This handleException method is previously defined as

	/**
	 * This method is called from SugarApplication->execute and it will bootstrap the entire controller process
	 */
	final public function execute()
    {

        try
        {
            $this->process();
            if(!empty($this->view))
            {
                $this->processView();
            }
            elseif(!empty($this->redirect_url))
            {
            			$this->redirect();
            }
        }
        catch (Exception $e)
        {
            $this->handleException($e);
        }



	}

    /**
      * Handle exception
      * @param Exception $e
      */
    protected function handleException(Exception $e)
    {
        $GLOBALS['log']->fatal('Exception in Controller: ' . $e->getMessage());
        $logicHook = new LogicHook();

        if (isset($this->bean))
        {
            $logicHook->setBean($this->bean);
            $logicHook->call_custom_logic($this->bean->module_dir, "handle_exception", $e);
        }
        else
        {
            $logicHook->call_custom_logic('', "handle_exception", $e);
        }
    }
This entry was posted in SugarCRM. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

One Comment

  1. C├ędric
    Posted March 21, 2013 at 7:02 am | Permalink

    You have some other undocumenten logic hools:
    – after_session_start
    – before_email_import/after_email_import called in SNIP workflows
    – after_entry_point

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Sage President\

Profiling Solutions, Inc
174 Carroll Street
Atlanta, GA 30312
Sales: 1 (866) 515-9959
Office Phone: (404) 525-8003
Office Fax: (404) 525-8005
info@profilingsolutions.com