perl

While working with Curses and Mouse I found, that my Mouse error message will not be displayed. I worked around it by capturing the message via eval, calling endwin; directly and displaying the error after that.

#!/usr/bin/perl

package Foo;
use Mouse;

use Curses::UI;

has _cui => (
    isa => 'Curses::UI',
    is => 'ro',
    default => sub { return new Curses::UI ( -clear_on_exit => 0 ) },
);

has _screen => (
    # _screen should be a 'Curses::UI::Window'
    isa => 'Curses::UI',
    is => 'ro',
    default => sub { return shift->_cui->add( 'screen', 'Window' ) },
);

package main;

use Curses;

eval { my $f = Foo->new(); };

if ($@) {
	endwin;
	print $@;
}