Closed beccon4 closed 5 years ago
I believe display_name
is a Types::Standard
or Type::Tiny
thing. Mabe Raisin should check if the type object can('display_name')
before trying to call it, and fall back to using name()
if display_name
is unavailable?
When I use MooseX::Types as parameters in Raisin, I'l get an exception as soon as params_requires gets executed with one of these. Int and Str is enough - not to mention subtypes.
Can't locate object method "display_name" via package "Moose::Meta::TypeConstraint" at /usr/share/perl5/MooseX/Types/TypeDecorator.pm line 219 MooseX::Types::TypeDecorator::_try_delegate('MooseX::Types::TypeDecorator=HASH(0x2f83338)', 'display_name') called at /usr/share/perl5/MooseX/Types/TypeDecorator.pm line 184 MooseX::Types::TypeDecorator::AUTOLOAD('MooseX::Types::TypeDecorator=HASH(0x2f83338)') called at /home/cbeckert/Raisin/lib/Raisin/Plugin/Swagger.pm line 351 Raisin::Plugin::Swagger::_param_type_object('Raisin::Param=HASH(0x2ecee70)') called at /home/cbeckert/Raisin/lib/Raisin/Plugin/Swagger.pm line 253 Raisin::Plugin::Swagger::_parameters_object('GET', 'ARRAY(0x1c37870)') called at /home/cbeckert/Raisin/lib/Raisin/Plugin/Swagger.pm line 213 Raisin::Plugin::Swagger::_operation_object('Raisin::Routes::Endpoint=HASH(0x2ececf0)') called at /home/cbeckert/Raisin/lib/Raisin/Plugin/Swagger.pm line 177 Raisin::Plugin::Swagger::_paths_object('ARRAY(0x2063970)') called at /home/cbeckert/Raisin/lib/Raisin/Plugin/Swagger.pm line 94 Raisin::Plugin::Swagger::_spec_20('Raisin::Plugin::Swagger=HASH(0x2ec91c8)') called at /home/cbeckert/Raisin/lib/Raisin/Plugin/Swagger.pm line 23 Raisin::Plugin::Swagger::__ANON__('Raisin=HASH(0x2063a00)') called at /home/cbeckert/Raisin/lib/Raisin.pm line 155 Raisin::psgi('Raisin=HASH(0x2063a00)', 'HASH(0x2ff9ec8)') called at /home/cbeckert/Raisin/lib/Raisin.pm line 93 Raisin::__ANON__('HASH(0x2ff9ec8)') called at /home/cbeckert/perl5/lib/perl5/Plack/Middleware/CrossOrigin.pm line 114 Plack::Middleware::CrossOrigin::call('Plack::Middleware::CrossOrigin=HASH(0x2f8f988)', 'HASH(0x2ff9ec8)') called at /usr/share/perl5/Plack/Component.pm line 50 Plack::Component::__ANON__('HASH(0x2ff9ec8)') called at /home/cbeckert/Raisin/lib/Raisin/Middleware/Formatter.pm line 46 Raisin::Middleware::Formatter::call('Raisin::Middleware::Formatter=HASH(0x2fdf760)', 'HASH(0x2ff9ec8)') called at /usr/share/perl5/Plack/Component.pm line 50 Plack::Component::__ANON__('HASH(0x2ff9ec8)') called at /usr/share/perl5/Plack/Middleware/Lint.pm line 24 Plack::Middleware::Lint::call('Plack::Middleware::Lint=HASH(0x16880a0)', 'HASH(0x2ff9ec8)') called at /usr/share/perl5/Plack/Component.pm line 50 Plack::Middleware::StackTrace::try {...} at /usr/share/perl5/Try/Tiny.pm line 79 eval {...} at /usr/share/perl5/Try/Tiny.pm line 72 Plack::Middleware::StackTrace::call('Plack::Middleware::StackTrace=HASH(0x20636b8)', 'HASH(0x2ff9ec8)') called at /usr/share/perl5/Plack/Component.pm line 50 Plack::Component::__ANON__('HASH(0x2ff9ec8)') called at /usr/share/perl5/Plack/Middleware/AccessLog.pm line 24 Plack::Middleware::AccessLog::call('Plack::Middleware::AccessLog=HASH(0x2eaeac0)', 'HASH(0x2ff9ec8)') called at /usr/share/perl5/Plack/Component.pm line 50 Plack::Component::__ANON__('HASH(0x2ff9ec8)') called at /usr/share/perl5/Plack/Middleware/ContentLength.pm line 10 Plack::Middleware::ContentLength::call('Plack::Middleware::ContentLength=HASH(0x2fe0048)', 'HASH(0x2ff9ec8)') called at /usr/share/perl5/Plack/Component.pm line 50 Plack::Component::__ANON__('HASH(0x2ff9ec8)') called at /usr/share/perl5/Plack/Util.pm line 142 eval {...} at /usr/share/perl5/Plack/Util.pm line 142 Plack::Util::run_app('CODE(0x2fe0000)', 'HASH(0x2ff9ec8)') called at /usr/share/perl5/HTTP/Server/PSGI.pm line 170 HTTP::Server::PSGI::handle_connection('HTTP::Server::PSGI=HASH(0x2fdfeb0)', 'HASH(0x2ff9ec8)', 'IO::Socket::INET=GLOB(0x2fe0168)', 'CODE(0x2fe0000)') called at /usr/share/perl5/HTTP/Server/PSGI.pm line 129 HTTP::Server::PSGI::accept_loop('HTTP::Server::PSGI=HASH(0x2fdfeb0)', 'CODE(0x17cb6d0)') called at /usr/share/perl5/HTTP/Server/PSGI.pm line 55 HTTP::Server::PSGI::run('HTTP::Server::PSGI=HASH(0x2fdfeb0)', 'CODE(0x17cb6d0)') called at /usr/share/perl5/Plack/Handler/HTTP/Server/PSGI.pm line 14 Plack::Handler::HTTP::Server::PSGI::run('Plack::Handler::Standalone=HASH(0x2fe0258)', 'CODE(0x17cb6d0)') called at /usr/share/perl5/Plack/Loader.pm line 84 Plack::Loader::run('Plack::Loader=HASH(0x1479398)', 'Plack::Handler::Standalone=HASH(0x2fe0258)') called at /usr/share/perl5/Plack/Runner.pm line 277 Plack::Runner::run('Plack::Runner=HASH(0x1203150)') called at /usr/bin/plackup line 10
Using Moose::Util::TypeConstraints doesnt help either. A simple Setup such as:
subtype 'bla' ,as 'Str'; ... and then params requires('mac', type => 'bla');
produces:
Can't locate object method "name" via package "bla" (perhaps you forgot to load "bla"?) at /home/cbeckert/Raisin/lib/Raisin/Plugin/Swagger.pm line 382 Raisin::Plugin::Swagger::_param_type('bla') called at /home/cbeckert/Raisin/lib/Raisin/Plugin/Swagger.pm line 242 Raisin::Plugin::Swagger::_parameters_object('GET', 'ARRAY(0x28aa768)') called at /home/cbeckert/Raisin/lib/Raisin/Plugin/Swagger.pm line 213 Raisin::Plugin::Swagger::_operation_object('Raisin::Routes::Endpoint=HASH(0x27fc9b0)') called at /home/cbeckert/Raisin/lib/Raisin/Plugin/Swagger.pm line 177 Raisin::Plugin::Swagger::_paths_object('ARRAY(0x2cce088)') called at /home/cbeckert/Raisin/lib/Raisin/Plugin/Swagger.pm line 94 Raisin::Plugin::Swagger::_spec_20('Raisin::Plugin::Swagger=HASH(0x3a7b600)') called at /home/cbeckert/Raisin/lib/Raisin/Plugin/Swagger.pm line 23 Raisin::Plugin::Swagger::__ANON__('Raisin=HASH(0x2cce118)') called at /home/cbeckert/Raisin/lib/Raisin.pm line 155 Raisin::psgi('Raisin=HASH(0x2cce118)', 'HASH(0x3ae7560)') called at /home/cbeckert/Raisin/lib/Raisin.pm line 93 Raisin::__ANON__('HASH(0x3ae7560)') called at /home/cbeckert/perl5/lib/perl5/Plack/Middleware/CrossOrigin.pm line 114 Plack::Middleware::CrossOrigin::call('Plack::Middleware::CrossOrigin=HASH(0x3b0fd80)', 'HASH(0x3ae7560)') called at /usr/share/perl5/Plack/Component.pm line 50 Plack::Component::__ANON__('HASH(0x3ae7560)') called at /home/cbeckert/Raisin/lib/Raisin/Middleware/Formatter.pm line 46 Raisin::Middleware::Formatter::call('Raisin::Middleware::Formatter=HASH(0x3b4f9b0)', 'HASH(0x3ae7560)') called at /usr/share/perl5/Plack/Component.pm line 50 Plack::Component::__ANON__('HASH(0x3ae7560)') called at /usr/share/perl5/Plack/Middleware/Lint.pm line 24 Plack::Middleware::Lint::call('Plack::Middleware::Lint=HASH(0x219cf30)', 'HASH(0x3ae7560)') called at /usr/share/perl5/Plack/Component.pm line 50 Plack::Middleware::StackTrace::try {...} at /usr/share/perl5/Try/Tiny.pm line 79 eval {...} at /usr/share/perl5/Try/Tiny.pm line 72 Plack::Middleware::StackTrace::call('Plack::Middleware::StackTrace=HASH(0x251f3b8)', 'HASH(0x3ae7560)') called at /usr/share/perl5/Plack/Component.pm line 50 Plack::Component::__ANON__('HASH(0x3ae7560)') called at /usr/share/perl5/Plack/Middleware/AccessLog.pm line 24 Plack::Middleware::AccessLog::call('Plack::Middleware::AccessLog=HASH(0x38e8658)', 'HASH(0x3ae7560)') called at /usr/share/perl5/Plack/Component.pm line 50 Plack::Component::__ANON__('HASH(0x3ae7560)') called at /usr/share/perl5/Plack/Middleware/ContentLength.pm line 10 Plack::Middleware::ContentLength::call('Plack::Middleware::ContentLength=HASH(0x3b50fb8)', 'HASH(0x3ae7560)') called at /usr/share/perl5/Plack/Component.pm line 50 Plack::Component::__ANON__('HASH(0x3ae7560)') called at /usr/share/perl5/Plack/Util.pm line 142 eval {...} at /usr/share/perl5/Plack/Util.pm line 142 Plack::Util::run_app('CODE(0x3b50f58)', 'HASH(0x3ae7560)') called at /usr/share/perl5/HTTP/Server/PSGI.pm line 170 HTTP::Server::PSGI::handle_connection('HTTP::Server::PSGI=HASH(0x3b50dd8)', 'HASH(0x3ae7560)', 'IO::Socket::INET=GLOB(0x3b0a330)', 'CODE(0x3b50f58)') called at /usr/share/perl5/HTTP/Server/PSGI.pm line 129 HTTP::Server::PSGI::accept_loop('HTTP::Server::PSGI=HASH(0x3b50dd8)', 'CODE(0x38e88c8)') called at /usr/share/perl5/HTTP/Server/PSGI.pm line 55 HTTP::Server::PSGI::run('HTTP::Server::PSGI=HASH(0x3b50dd8)', 'CODE(0x38e88c8)') called at /usr/share/perl5/Plack/Handler/HTTP/Server/PSGI.pm line 14 Plack::Handler::HTTP::Server::PSGI::run('Plack::Handler::Standalone=HASH(0x219cbe8)', 'CODE(0x38e88c8)') called at /usr/share/perl5/Plack/Loader/Restarter.pm line 32 Plack::Loader::Restarter::_fork_and_start('Plack::Loader::Restarter=HASH(0x1cf23a0)', 'Plack::Handler::Standalone=HASH(0x219cbe8)') called at /usr/share/perl5/Plack/Loader/Restarter.pm line 61 Plack::Loader::Restarter::run('Plack::Loader::Restarter=HASH(0x1cf23a0)', 'Plack::Handler::Standalone=HASH(0x219cbe8)') called at /usr/share/perl5/Plack/Runner.pm line 277 Plack::Runner::run('Plack::Runner=HASH(0x1ce9278)') called at /usr/bin/plackup line 10 127.0.0.1 - - [18/Oct/2018:17:25:30 +0200] "GET /swagger HTTP/1.1" 500 23459 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0"