@throws \ErrorException

@return \Thelia\ImportExport\Export\ExportHandler
194087
public function getHandleClassInstance()
    {
        $class = $this->getHandleClass();

        if ($class[0] !== '\\') {
            $class = '\\' . $class;
        }

        if (!class_exists($class)) {
            $this->delete();

            throw new \ErrorException(
                Translator::getInstance()->trans(
                    'The class "%class" doesn\'t exist',
                    [
                        '%class' => $class
                    ]
                )
            );
        }

        $instance = new $class();

        if (!$instance instanceof AbstractExport) {
            $this->delete();

            throw new \ErrorException(
                Translator::getInstance()->trans(
                    'The class "%class" must extend %baseClass',
                    [
                        '%class' => $class,
                        '%baseClass' => 'Thelia\\ImportExport\\Export\\AbstractExport',
                    ]
                )
            );
        }

        return $instance;
    }
1030013
protected function getImportType()
    {
        $type = $this->importType;

        if (strlen($type) != 1 || !array_key_exists($type, $this->objects)) {
            throw new Exception('Error unknown command: ' . $type);
        } else {
            return $this->objects[$type];
        }
    }
546887
protected function getAvailableImportHandlers()
    {
        if (empty($this->availableHandlers)) {
            $this->availableHandlers = [
                new tao_models_classes_import_RdfImporter(),
                new tao_models_classes_import_CsvImporter()
            ];
        }

        return $this->availableHandlers;
    }
246097
public function handleException($ex)
    {
        if ($ex instanceof \Exception || $ex instanceof \Throwable) {
            throw new \ErrorException($ex->getMessage(), $ex->getCode(), E_ALL, $ex->getFile(), $ex->getLine());
        }
    }
782813
public function getExporter()
	{
		// Derive the class name from the driver.
		$class = '\\Joomla\\Database\\' . ucfirst($this->name) . '\\' . ucfirst($this->name) . 'Exporter';

		// Make sure we have an exporter class for this driver.
		if (!class_exists($class))
		{
			// If it doesn't exist we are at an impasse so throw an exception.
			throw new Exception\UnsupportedAdapterException('Database Exporter not found.');
		}

		/** @var $o DatabaseExporter */
		$o = new $class;
		$o->setDbo($this);

		return $o;
	}
1223048
public function export()
    {
        if (!$this->isXmlHttpRequest()) {
            throw new \Exception('Only ajax call allowed.');
        }

        if (!$this->hasRequestParameter(self::PARAMETER_DELIVERY_CLASS_URI) && !$this->hasRequestParameter(self::PARAMETER_DELIVERY_URI)) {
            throw new \common_Exception('Parameter "'. self::PARAMETER_DELIVERY_CLASS_URI .'" or "'. self::PARAMETER_DELIVERY_URI .'" missing');
        }

        $resourceUri = $this->hasRequestParameter(self::PARAMETER_DELIVERY_URI)
            ? \tao_helpers_Uri::decode($this->getRequestParameter(self::PARAMETER_DELIVERY_URI))
            : \tao_helpers_Uri::decode($this->getRequestParameter(self::PARAMETER_DELIVERY_CLASS_URI));

        /** @var ResultsExporter $exporter */
        $exporter = $this->propagate(new ResultsExporter($resourceUri, ResultsService::singleton()));

        return $this->returnTaskJson($exporter->createExportTask());
    }
1333691
protected static function handleError()
	{
		if(self::$errorHandler === NULL)
		{
			self::$errorHandler = function ($type, $message, $file, $line) {
				throw new \RuntimeException($message);
			};
		}
		
		return self::$errorHandler;
	}
643986
public function getAvailableImportHandlers()
    {
        $returnValue = parent::getAvailableImportHandlers();

        foreach (array_keys($returnValue) as $key) {
            if ($returnValue[$key] instanceof \tao_models_classes_import_CsvImporter) {
                $importer = new CsvImporter();
                $importer->setValidators($this->getValidators());
                $returnValue[$key] = $importer;
            }
        }

        return $returnValue;
    }
1366657
protected function normalizeErrorHandler(callable $errorHandler)
    {
        if ($errorHandler instanceof ErrorHandler) {
            return $errorHandler;
        }

        $legacyResponseGenerator = function (
            $e,
            ServerRequestInterface $request,
            ResponseInterface $response
        ) use ($errorHandler) {
            return $errorHandler($request, $response, $e);
        };

        $errorHandler = new ErrorHandler(new Response(), $legacyResponseGenerator);
        return $errorHandler;
    }
85805
public function export()
    {
        // Disable any access to use of WorkflowExport if user has no SecurityAdmin access
        if (!Permission::check('CMS_ACCESS_SecurityAdmin')) {
            throw new Exception(_t('SilverStripe\\ErrorPage\\ErrorPage.CODE_403', '403 - Forbidden'), 403);
        }
        $def = $this->getDefinition();
        $templateData = new ArrayData(array(
            'ExportMetaData' => $this->ExportMetaData(),
            'ExportActions' => $def->Actions(),
            'ExportUsers' => $def->Users(),
            'ExportGroups' => $def->Groups()
        ));
        return $this->format($templateData);
    }
1252237
private function registerExceptionHandler()
    {
        $handler = $this->app[ExceptionHandlerContract::class];

        $this->singleton(ExceptionHandlerContract::class, function ($app) use ($handler) {
            return new Exceptions\Handler($app[Contracts\Tracker::class], $handler);
        });
    }
704188
protected function defineErrorHandler()
    {
        $errorRender = $this->obtainErrorRender();
        
        //If not render to use
        if ($errorRender === false) {
            return;
        }

        //add the handler for errors
        set_error_handler([$this, 'errorHandler']);
        
        \BFW\Application::getInstance()
            ->getMonolog()
            ->getLogger()
            ->debug('New error handler defined.')
        ;
    }
1245015
public function getNotAllowedHandler() : NotAllowedHandlerInterface
    {
        if (!$this->notAllowedHandler) {
            $this->notAllowedHandler = new NotAllowedHandler(
                (bool) $this->getConfiguration('displayErrors')
            );
        }

        return $this->notAllowedHandler;
    }
20257
protected function setupExporter()
    {
        if ($scope = Input::get(Exporter::$queryName)) {
            $this->model()->usePaginate(false);

            call_user_func($this->builder, $this);

            (new Exporter($this))->resolve($this->exporter)->withScope($scope)->export();
        }
    }
1220525
public function error()
    {
        $errorNo = $_FILES[$this->file]['error'] ?? NULL;

        if( $errorNo === NULL )
        {
            return $this->getLang['upload:unknownError'];
        }

        if( is_array($errorNo) )
        {
            $errno = 0;

            foreach( $errorNo as $no )
            {
                if( ! empty($no) )
                {
                    $errno = $no;
                    break;
                }
            }

            $errorNo = $errno;
        }

        $lang = $this->getLang;

        $this->errors =
        [
            '0'  => "scc",            
            '1'  => $lang['upload:1'],
            '2'  => $lang['upload:2'], 
            '3'  => $lang['upload:3'], 
            '4'  => $lang['upload:4'], 
            '6'  => $lang['upload:6'], 
            '7'  => $lang['upload:7'], 
            '8'  => $lang['upload:8'], 
            '9'  => $lang['upload:9'],
            '10' => $lang['upload:10']
        ];
       
        if( ! empty($this->manuelError) )
        {
            return $this->errors[$this->manuelError];
        }
        elseif( ! empty($this->extensionControl) )
        {
            return $this->extensionControl;
        }
        elseif( ! empty($this->errors[$errorNo]) )
        {
            if( $this->errors[$errorNo] === "scc" )
            {
                return false;
            }
            return $this->errors[$errorNo];
        }
        else
        {
            return $lang['upload:unknownError'];
        }
    }
205301
protected function defineExceptionHandler()
    {
        $exceptionRender = $this->obtainExceptionRender();
        
        //If not render to use
        if ($exceptionRender === false) {
            return;
        }
        
        //add the handler for exceptions
        set_exception_handler([$this, 'exceptionHandler']);
        
        \BFW\Application::getInstance()
            ->getMonolog()
            ->getLogger()
            ->debug('New exception handler defined.')
        ;
    }
35934
protected function newLoggerHandlerImpl()
    {
        $config  = $this->get('config');
        $factory = $config->get('psx_logger_factory');

        if ($factory instanceof \Closure) {
            return $factory($config);
        } else {
            $level = $config->get('psx_log_level');
            $level = !empty($level) ? $level : Logger::ERROR;

            $handler = new ErrorLogHandler(ErrorLogHandler::OPERATING_SYSTEM, $level, true, true);
            $handler->setFormatter(new ErrorFormatter());

            return $handler;
        }
    }