From: Arthur Axel 'fREW' Schmidt Date: Fri, 16 Jul 2010 01:12:46 +0000 (-0500) Subject: better error message for blank schema X-Git-Tag: v0.001003~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class-DeploymentHandler.git;a=commitdiff_plain;h=7ae4c20759f7cffd15912aec8784111ceb5543f2 better error message for blank schema --- diff --git a/lib/DBIx/Class/DeploymentHandler/Dad.pm b/lib/DBIx/Class/DeploymentHandler/Dad.pm index ad76a7a..86043e8 100644 --- a/lib/DBIx/Class/DeploymentHandler/Dad.pm +++ b/lib/DBIx/Class/DeploymentHandler/Dad.pm @@ -7,6 +7,7 @@ use Method::Signatures::Simple; require DBIx::Class::Schema; # loaded for type constraint use Carp::Clan '^DBIx::Class::DeploymentHandler'; use DBIx::Class::DeploymentHandler::Logger; +use DBIx::Class::DeploymentHandler::Types; use Log::Contextual ':log', -package_logger => DBIx::Class::DeploymentHandler::Logger->new({ env_prefix => 'DBICDH' @@ -34,7 +35,7 @@ sub _build_to_version { $_[0]->schema_version } has schema_version => ( is => 'ro', - isa => 'Str', + isa => 'StrSchemaVersion', lazy_build => 1, ); diff --git a/lib/DBIx/Class/DeploymentHandler/Types.pm b/lib/DBIx/Class/DeploymentHandler/Types.pm index 67e4780..2cefab6 100644 --- a/lib/DBIx/Class/DeploymentHandler/Types.pm +++ b/lib/DBIx/Class/DeploymentHandler/Types.pm @@ -11,8 +11,16 @@ subtype 'DBIx::Class::DeploymentHandler::Databases' coerce 'DBIx::Class::DeploymentHandler::Databases' => from 'Str' => via { [$_] }; -no Moose::Util::TypeConstraints; +subtype 'StrSchemaVersion' + => as 'Str' + => message { + defined $_ + ? "Schema version (currently '$_') must be a string" + : 'Schema version must be defined' + }; + +no Moose::Util::TypeConstraints; 1; # vim: ts=2 sw=2 expandtab