Esempio n. 1
0
/**
 * Captura todas as exceções não tratadas do sistema.
 * 
 * @param Exception $e
 */
function throwNewExceptionFromAnywhere($e)
{
    $setup = BraghimSistemas::getInstance();
    // Tenta carregar a tela de erro do MODULO.
    try {
        $setup->mvc = $setup->resolve($setup->mvc->moduleName, 'error', 'error');
    } catch (Exception $ex) {
        // Tenta carregar a tela de erro
        // padrao do framework.
        try {
            $setup->mvc = $setup->resolve('ModuleError', 'error', 'error', __DIR__ . DIRECTORY_SEPARATOR . 'library');
        } catch (Exception $ex2) {
            if (function_exists('createSystemLog')) {
                createSystemLog($e);
            }
            echo "Exception sem possibilidade de tratamento.";
            dump($e);
        }
    }
    $setup->mvc->exception = $e;
    // Ultima tentativa de dar certo,
    // se chegar aqui e der erro então
    // o projeto esta configurado incorretamente.
    try {
        $setup->run();
    } catch (Exception $ex3) {
        if (function_exists('createSystemLog')) {
            createSystemLog($e);
        }
        echo "Exception sem possibilidade de tratamento.";
        dump($ex3);
    }
}
 /**
  * Primeiro metodo a ser chamado.
  * Configura o sistema.
  * 
  * @return BraghimSistemas
  * @throws Exception
  */
 public static function setup($modulesPath = null)
 {
     if (self::$instance == null) {
         if (!$modulesPath) {
             throw new \Exception("Necessário informar a pasta onde os módulos serão criados.");
         }
         self::$instance = new self(trim($modulesPath, DIRECTORY_SEPARATOR));
     }
     return self::$instance;
 }