src/Module/ExceptionHandler/CalgamoHtmlExceptionHandlerModule.php
public function install(ApplicationInterface $app)
    {
        try{
            $html_dir = $app->fileSystem()->getDirectory('html');

            // add HTTP error header handler
            $ex_handler = new CalgamoExceptionHandlerAdapter(new HttpErrorHeaderExceptionHandler());
            $app->addExceptionHandler($ex_handler);

            $app->eventstream()->channel(Channels::SYSTEM)->push(Events::EX_HANDLER_ADDED, $ex_handler);

            // add error document handler
            $ex_handler = new CalgamoExceptionHandlerAdapter(new ErrorDocumentExceptionHandler(
                new class($html_dir) implements HttpErrorDocumentProviderInterface {
                    private $html_dir;
                    public function __construct($html_dir)
                    {
                        $this->html_dir = $html_dir;
                    }
                    public function getErrorDocument(int $status) : string
                    {
                        return file_get_contents($this->html_dir . '/' . $status . '.html');
                    }
                }
            ));
            $app->addExceptionHandler($ex_handler);

            $app->eventstream()->channel(Channels::SYSTEM)->push(Events::EX_HANDLER_ADDED, $ex_handler);
        }
        catch(\Throwable $e)
        {
            throw new ModuleInstallationException(self::class, $e->getMessage(), $e);
        }
    }
public function install(ApplicationInterface $app)
    {
        try{
            $html_dir = $app->fileSystem()->getDirectory('html');

            // add HTTP error header handler
            $ex_handler = new CalgamoExceptionHandlerAdapter(new HttpErrorHeaderExceptionHandler());
            $app->addExceptionHandler($ex_handler);

            $app->eventstream()->channel(Channels::SYSTEM)->push(Events::EX_HANDLER_ADDED, $ex_handler);

            // add error document handler
            $ex_handler = new CalgamoExceptionHandlerAdapter(new ErrorDocumentExceptionHandler(
                new class($html_dir) implements HttpErrorDocumentProviderInterface {
                    private $html_dir;
                    public function __construct($html_dir)
                    {
                        $this->html_dir = $html_dir;
                    }
                    public function getErrorDocument(int $status) : string
                    {
                        return file_get_contents($this->html_dir . '/' . $status . '.html');
                    }
                }
            ));
            $app->addExceptionHandler($ex_handler);

            $app->eventstream()->channel(Channels::SYSTEM)->push(Events::EX_HANDLER_ADDED, $ex_handler);
        }
        catch(\Throwable $e)
        {
            throw new ModuleInstallationException(self::class, $e->getMessage(), $e);
        }
    }
public function install ( ApplicationInterface $ app ) { try { $ html_dir = $ app -> fileSystem ( ) -> getDirectory ( 'html' ) ; // add HTTP error header handler $ ex_handler = new CalgamoExceptionHandlerAdapter ( new HttpErrorHeaderExceptionHandler ( ) ) ; $ app -> addExceptionHandler ( $ ex_handler ) ; $ app -> eventstream ( ) -> channel ( Channels :: SYSTEM ) -> push ( Events :: EX_HANDLER_ADDED , $ ex_handler ) ; // add error document handler $ ex_handler = new CalgamoExceptionHandlerAdapter ( new ErrorDocumentExceptionHandler ( new class ( $ html_dir ) implements HttpErrorDocumentProviderInterface { private $ html_dir ; public function __construct ( $ html_dir ) { $ this -> html_dir = $ html_dir ; } public function getErrorDocument ( int $ status ) : string { return file_get_contents ( $ this -> html_dir . '/' . $ status . '.html' ) ; } } ) ) ; $ app -> addExceptionHandler ( $ ex_handler ) ; $ app -> eventstream ( ) -> channel ( Channels :: SYSTEM ) -> push ( Events :: EX_HANDLER_ADDED , $ ex_handler ) ; } catch ( \ Throwable $ e ) { throw new ModuleInstallationException ( self :: class , $ e -> getMessage ( ) , $ e ) ; } }
Install module

@param ApplicationInterface $app

@throws ModuleInstallationException
Install module