public function handleErrors($severity, $message, $filepath, $line)
    {
        if (error_reporting() == 0 || $severity == E_STRICT)
            return;

        if (false !== strpos($filepath, '/')) {
            $x = explode('/', $filepath);
            $filepath = $x[count($x)-3].'/'.$x[count($x)-2].'/'.end($x);
        }

        $mess = $this->getLevel($severity).'('.$severity.'):  '.$message. ' in '.$filepath.' on line '.$line;

        /*
         * shouldn't need to log the error here as the exception will handle the logging.
         */
        /*
        $context = (isset($_SERVER['CONTEXT']) ? $_SERVER['CONTEXT'] : 'none');
        if (array_key_exists('SITE', $_SERVER)) {
            $appName = (string) $_SERVER['SITE']['slug'];
            if ($appName === $context) {
                $appName = $this->SiteService->getAnchoredSite()->Slug;
            }
        } else {
            $appName = $_SERVER['SERVER_NAME'];
        }
        error_log("[{$this->environment}][$appName][$context][PHP_ERROR] " .  $mess);
        */

        if($severity == E_RECOVERABLE_ERROR)
            throw new Exception($mess);

        if (($severity & error_reporting()) == $severity) {
            if($this->redeployOnError && isset($this->ApplicationContext))
                $this->ApplicationContext->clearContextFiles();

            throw new Exception($mess);
        }

        return true;
    }